Q:

Error: Incompatible element type String for collection

I am trying to create a list with name and checkbox fields and when save is clicked, the names that are selected should be saved just as shown in the example here. My issue is if I use sObject in place of string (sess), selected.add(check.sess); I am not getting error. But can anyone please suggest how to get the following code working.
Thanks.
Exact Error: Incompatible element type String for collection of listex.s
Code:
public class listex{

    public list<s> inte;

    public list<s> getsessions(){
        if(inte == null){
            inte = new list<s>();
            for(integer i=1;i<4;i++){
                inte.add(new s('session'+i));
            }
        }
        return inte;
    }

    public class s{
        public string sess{get;set;}
        public integer numb{get;set;}       
        public boolean checked{get;set;}
        public s(string str){
            this.sess = str;
            this.checked = false;
        }
    }

    public pagereference save(){
        list<s> selected = new list<s>();
        for(s check : getsessions()){
            if(check.checked == true){
                selected.add(check.sess);
            }
        }
        system.debug(selected);
        return null;
    }
}

A:

Your list selected should be a list of String (List<String> selected = new List<String>()) to add check.sess because sess is a String field

