function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
affableaffable 

Initial term of field expression must be a concrete SObject: LIST<College.StudentClass>

 

public class College
{
 // college name.
 Public Static final String CollegeName ='Tirumala Engg College';
 // college address.
 public Static final String  CollegeAdress='kesaraGutta,Bogaram,Hyderabad.';
 //college Year of Establishment.
 public Static final Integer DOE=1990;
 // creating Student class
 public class StudentClass
  {
  // creating properties for the required Student feilds(student number,student name,student address etc).
   public Integer sNo{get;set;}
   public String sName{get;set;}
   public String sAddress{get;set;}
   public Integer doj{get;set;}
   public String course{get;set;}
  }
  public class InstructorClass
  {
  // creating properties for Instructor feilds.
   public Integer iNo{get;set;}
   public String iName{get;set;}
   public String iQualification{get;set;}
   public Integer iDeptno{get;set;}
   }
   public class DeptClass
  {
  //creating properties for Department feilds.
   public Integer deptNo{get;set;}
   public String deptName{get;set;}
   public String deptLoc{get;set;}
   }
   //creating a list of students
   public List<StudentClass> students =new List<StudentClass>();
   ////creating a list of Instructors
   public List<InstructorClass> instructors =new List<InstructorClass>();
   //creating a list of Departments
   public List<DeptClass> departments =new List<DeptClass>();
   
  /* public String College()
   {
    return 'Welcome to '+ College.CollegeName;
    }*/
    
    public static StudentClass searchStudent(Integer stNo,List<StudentClass> Stds)
    {
       for(College.StudentClass student:stds)
         {
          if(Stds.sNo==stNo)
           {
           return student;
           }
           }
           }
    }
    
    hi can tell what's the error , am unable to understand error. any suggestion
   

Best Answer chosen by Admin (Salesforce Developers) 
jungleeejungleee

The  List which you're using are not of concret SObject, You will have the follwing changes:

 

Add the __c to the custom Object name

List<StudentClass__c> students =new List<StudentClass__c>();

 

Please follow the same to the other Lists as well

 

Hope this helps!!

 

Regards

Sam

All Answers

TheIntegratorTheIntegrator

I think

  if(Stds.sNo==stNo)

 

should be

  if(student.sNo==stNo)

jungleeejungleee

The  List which you're using are not of concret SObject, You will have the follwing changes:

 

Add the __c to the custom Object name

List<StudentClass__c> students =new List<StudentClass__c>();

 

Please follow the same to the other Lists as well

 

Hope this helps!!

 

Regards

Sam

This was selected as the best answer
Irenee LisonopIrenee Lisonop
The error you're encountering is occurring because of a typographical mistake in your code. In the searchStudent method, you have defined the parameter as List<StudentClass> Stds, but you are using stds (with a lowercase 's') in the for loop and the if condition. To resolve the issue, you should change Stds to stds in the if condition. Here's the corrected code:
public static StudentClass searchStudent(Integer stNo, List<StudentClass> stds) {
    for (College.StudentClass student : stds) {
        if (student.sNo == stNo) {
            return student;
        }
    }
    return null; // Added this line to handle the case when student is not found.
}


By making this change, the error should be resolved, and the searchStudent method should function correctly.
Latia OvalleLatia Ovalle
I also faced this problem and usually I am helped by a friend who is already working; now I have moved on to college and also have to solve problems like this, but the friend can't help me anymore and I turned to this source https://paperell.net/buy-term-paper to buy college term paper; this was the best idea of my life, because now I manage to do absolutely all my homework with his help and besides that when a problem like this occurs, the guys help me to solve it and most of all I like that it happens in very short time.