Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 23 of 23

Thread: Can any one tell me why I am getting an error

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can any one tell me why I am getting an error

    This my main


    import java.util.*;

    public class StudentList2 {

    public static void main(String[] args) {
    // TODO Auto-generated method stub

    ArrayList<StudentApp2> studentlist2 = new ArrayList<StudentApp2>();
    StudentApp2 nextStudent;

    String fname;
    String sname;
    int grade;
    int num = 3;

    Scanner kb = new Scanner(System.in);

    /// Do



    /// while



    ///public void enterStudents();{
    for (int i=0; i < 3; i++){

    System.out.println("Enter Firstname");
    fname = kb.nextLine();


    System.out.println("Enter Surname");
    sname = kb.nextLine();


    System.out.println("Enter Grade");
    grade = kb.nextInt();
    kb.nextLine();


    nextStudent = new StudentApp2 (fname,sname,grade);
    studentlist2.add(nextStudent);
    }
    }

    //public void ListSTud()
    {
    // String mark = "";
    for (int j = 0; j < 3; j++){

    System.out.println(StudentList2.get(j).toString()) ;


    }

    }



    }


    This my class


    import java.util.*;

    public class StudentApp2 {

    private String fname;
    private String sname;
    private int grade;
    private String mark;


    public StudentApp2 (String ipName, String ipsecondName, int ipgrade){
    fname = ipName;
    sname = ipsecondName;
    grade = ipgrade;
    getGrade();
    }


    public String toString (){
    return("The name of this student is "+fname+" "+sname+" The grade is "+grade+" "
    + "The mark is "+mark+" " );
    }


    public String getFname() {



    return fname;
    }


    public void setFname(String fname) {
    this.fname = fname;
    }


    public String getSname() {



    return sname;
    }


    public void setSname(String sname) {
    this.sname = sname;
    }


    public void getGrade() {






    if( grade >= 85 && grade <= 100 ){

    mark = "Distinction";
    }
    else if( grade >= 65 && grade <= 84 ){
    mark = "Merit";
    }
    else if( grade >= 40 && grade <= 64 ){

    mark = "Pass";
    }

    else if( grade <= 39 ){

    mark = "Fail";
    }



    }


    public void setGrade(int grade) {
    this.grade = grade;
    }
    }

    --- Update ---

    Sorry the is in the main at the end with my get from toString


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Can any one tell me why I am getting an error

    Too much code, too little accompanying info.

    Read the Announcement topic at the topic of the sub-forum and learn how to post your code in code tags, then edit your post to post the code correctly, ask a question or describe what you want help with, and post any errors you're getting.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    To wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Member
    Join Date
    Sep 2013
    Posts
    70
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Default Re: Can any one tell me why I am getting an error

    I hope I am mistaken but it appears as if you just copied one of your peers code and commented out to change the appearance of the program. By commenting out the methods in your main class and placing the code into your main method you now have an issue with extra closing brackets.

    example:
    ////
    // Correct amount of brackets
    ////
    { // Open Class
       { // Open Main
       } // Close Main
    } // Close Class
     
    ////
    // Possible Incorrect ways
    ////
     
    // Not enough closing brackets
    { // Open Class
       { // Open Main
          { // Open a statement/loop/switch/etc... in main
          } // Close of statement/loop/switch/etc...
      }// Closes Main
    // Missing a closing for the class.
     
    // Too many closing brackets
    { // Class code start
       { //Main
       } //Main close
    //.... Some code here not in a method and is not variable declaration is not a good thing
    } // Class close
    //.... More code outside of class = bad
    { // Opening what? Class was already closed and no inner class was done.
    }

    As I've said I hope I am wrong it would be bad to get a fellow classmate in trouble. Simply changing variable/method names and commenting out a few things does not mean it is different.

  5. #5
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

    This my main and my own code not copyed like someone said in a post earlier

     
    import java.util.*;
     
    public class StudentList2 {
     
    public static void main(String[] args) {
    // TODO Auto-generated method stub
     
    ArrayList<StudentApp2> studentlist2 = new ArrayList<StudentApp2>();
    StudentApp2 nextStudent;
     
    String fname;
    String sname;
    int grade;
    int num = 3;
     
    Scanner kb = new Scanner(System.in);
     
    /// Do
     
    Only have commented out because this the next part I must do,add a menu and add and delete students with a do while and 3 case's.
     
    /// while
     
     
     
    ///public void enterStudents();{
    for (int i=0; i < 3; i++){
     
    System.out.println("Enter Firstname");
    fname = kb.nextLine();
     
     
    System.out.println("Enter Surname");
    sname = kb.nextLine();
     
     
    System.out.println("Enter Grade");
    grade = kb.nextInt();
    kb.nextLine();
     
     
    nextStudent = new StudentApp2 (fname,sname,grade);
    studentlist2.add(nextStudent);
    }
    }
     
    //public void ListSTud()
    {
    // String mark = "";
    for (int j = 0; j < 3; j++){
     
    This is the line that I am getting the error,The rest is working fine
     
    error said studentlist2 cannot be resolved.
     
    System.out.println(studentlist2.get(j).toString()) ;
     
     
    }
     
    }	
     
     
     
    }


    This my class
     
    import java.util.*;
     
    public class StudentApp2 {
     
    private String fname;
    private String sname;
    private int grade;
    private String mark;
     
     
    public StudentApp2 (String ipName, String ipsecondName, int ipgrade){
    fname = ipName;
    sname = ipsecondName;
    grade = ipgrade;
    getGrade();
    }
     
     
    public String toString (){
    return("The name of this student is "+fname+" "+sname+" The grade is "+grade+" "
    + "The mark is "+mark+" " );
    }
     
     
    public String getFname() {
     
     
     
    return fname;
    }
     
     
    public void setFname(String fname) {
    this.fname = fname;
    }
     
     
    public String getSname() {
     
     
     
    return sname;
    }
     
     
    public void setSname(String sname) {
    this.sname = sname;
    }
     
     
    public void getGrade() {
     
     
     
     
     
     
    if( grade >= 85 && grade <= 100 ){
     
    mark = "Distinction";
    }
    else if( grade >= 65 && grade <= 84 ){
    mark = "Merit";
    }
    else if( grade >= 40 && grade <= 64 ){
     
    mark = "Pass";
    }
     
    else if( grade <= 39 ){
     
    mark = "Fail";
    }
     
     
     
    }
     
     
    public void setGrade(int grade) {
    this.grade = grade;
    }
    }


    --- Update ---

    import java.util.*;

    public class StudentList2 {

    public static void main(String[] args) {
    // TODO Auto-generated method stub

    ArrayList<StudentApp2> studentlist2 = new ArrayList<StudentApp2>();
    StudentApp2 nextStudent;

    String fname;
    String sname;
    int grade;
    int num = 3;

    Scanner kb = new Scanner(System.in);



    Only have commented out because this the next part I must do,add a menu and add and delete students with a do while and 3 case's.






    for (int i=0; i < 3; i++){

    System.out.println("Enter Firstname");
    fname = kb.nextLine();


    System.out.println("Enter Surname");
    sname = kb.nextLine();


    System.out.println("Enter Grade");
    grade = kb.nextInt();
    kb.nextLine();


    nextStudent = new StudentApp2 (fname,sname,grade);
    studentlist2.add(nextStudent);
    }
    }


    {
    // String mark = "";
    for (int j = 0; j < 3; j++){

    This is the line that I am getting the error,The rest is working fine

    error said studentlist2 cannot be resolved.

    System.out.println(studentlist2.get(j).toString()) ;


    }

    }



    }

    --- Update ---

     
    import java.util.*;
     
    public class StudentList2 {
     
    public static void main(String[] args) {
    // TODO Auto-generated method stub
     
    ArrayList<StudentApp2> studentlist2 = new ArrayList<StudentApp2>();
    StudentApp2 nextStudent;
     
    String fname;
    String sname;
    int grade;
    int num = 3;
     
    Scanner kb = new Scanner(System.in);
     
     
     
    Only have commented out because this the next part I must do,add a menu and add and delete students with a do while and 3 case's.
     
     
     
     
     
     
    for (int i=0; i < 3; i++){
     
    System.out.println("Enter Firstname");
    fname = kb.nextLine();
     
     
    System.out.println("Enter Surname");
    sname = kb.nextLine();
     
     
    System.out.println("Enter Grade");
    grade = kb.nextInt();
    kb.nextLine();
     
     
    nextStudent = new StudentApp2 (fname,sname,grade);
    studentlist2.add(nextStudent);
    }
    }
     
     
    {
    // String mark = "";
    for (int j = 0; j < 3; j++){
     
    This is the line that I am getting the error,The rest is working fine
     
    error said studentlist2 cannot be resolved.
     
    System.out.println(studentlist2.get(j).toString()) ;
     
     
    }
     
    }	
     
     
     
    }


    Sorry with post mistakes in the earlier post,
    Thanks all.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    Please edit your post and format the code so that nested statements are indented 3-4 spaces to show the program's logic. All statements should NOT start in the first column.

    Code should be in code tags. Text and comments should not be inside the code tags (unless properly coded as comments) as that makes the code it is mixed in with harder to read.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

     
    import java.util.*;
     
    public class StudentList2 {
     
    public static void main(String[] args) {
    // TODO Auto-generated method stub
     
    ArrayList<StudentApp2> studentlist2 = new ArrayList<StudentApp2>();
    StudentApp2 nextStudent;
     
    String fname;
    String sname;
    int grade;
    int num = 3;
     
    Scanner kb = new Scanner(System.in);
     
     
     
     
     
     
    for (int i=0; i < 3; i++){
     
    System.out.println("Enter Firstname");
     
    fname = kb.nextLine();
     
     
    System.out.println("Enter Surname");
     
    sname = kb.nextLine();
     
     
    System.out.println("Enter Grade");
    grade = kb.nextInt();
    kb.nextLine();
     
     
    nextStudent = new StudentApp2 (fname,sname,grade);
    studentlist2.add(nextStudent);
    }
    }
     
     
    {
    // String mark = "";
    for (int j = 0; j < 3; j++){
     
     
     
    System.out.println(studentlist2.get(j).toString()) ;
     
     
    }
     
    }

    This is the line that I am getting the error,The rest is working fine

    error said studentlist2 cannot be resolved.

    System.out.println(studentlist2.get(j).toString()) ;

    Only had commented out because this the next part I must do,add a menu and add and delete students with a do while and 3 case's.

    Have i posted it right now I hope?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    You missed this part:
    Please edit your post and format the code so that nested statements are indented 3-4 spaces to show the program's logic. All statements should NOT start in the first column.

    error said studentlist2 cannot be resolved.
    The compiler can not find a definition for studentlist2 that is in scope (within the same pair of {}s) as where it is being used. If you want to use a variable in multiple methods, make sure to define the variable outside of any methods so that all methods can see it.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

    I dont under stand this, as my studentlist2 is being called from my studentlist2 arraylist.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    What pair of {}s is studentlist2 defined in? Is the statement with the error within the same pair of {}s.
    In other words, is studentlist2 in scope where the error is?

    Because of the poor formatting of the code it is hard to see where the pairs of {} are.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

    Yes it is the first { after the for loop for (int j = 0; j < 3; j++){ and closed after the system.out statement.

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    If you format the code properly, it will be much easier to see where the paris of {}s are.

    class A_Class {
             int classVar;   //  define at class level; in Scope in all methods
     
    	 void meth1() {
    	    int aVar;    // define aVar; in Scope only within meth1
    		 ...
                 //  classVar in Scope here
    	 } // end meth1()
     
    	 void meth2() {
    	    //  aVar in NOT in SCOPE here
                 //  classVar in Scope here
    	 } //  end meth2()
    } // end class
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

     
    import java.util.*;
     
    public class StudentList2 {        ///class
     
    public static void main(String[] args) {      ///open main
    // TODO Auto-generated method stub
     
    ArrayList<StudentApp2> studentlist2 = new ArrayList<StudentApp2>();     ///ArrayList studentlist2
     
    StudentApp2 nextStudent;       ///class StudentApp2
     
    String fname;                  ///declare fname variable string
    String sname;                 ///declare sname variable string
    int grade;                      ///declare grade variable interger
    int num = 3;                  ///declare num variable integer. just for easy testing
     
    Scanner kb = new Scanner(System.in);          ///so can input with keyboard
     
     
     
     ///First for loop to enter firstname,Surname, and grade
     
     
    for (int i=0; i < 3; i++){              ///open for loop
     
    System.out.println("Enter Firstname");
     
    fname = kb.nextLine();
     
     
    System.out.println("Enter Surname");
     
    sname = kb.nextLine();
     
     
    System.out.println("Enter Grade");
    grade = kb.nextInt();
    kb.nextLine();
     
     
    nextStudent = new StudentApp2 (fname,sname,grade);       ///next student new object studentapp
    studentlist2.add(nextStudent);                                        ///add next student
     
    }     ///close for loop
     
     
     
     
    }      ///this was my mistake had main closed here
     
     
    {
    // String mark = "";
    for (int j = 0; j < 3; j++){
     
     
     
    System.out.println(studentlist2.get(j).toString()) ;
     
     
    }
     
    }



    Thanks had to run through the code had to many {} brackets
    Must do a do while statment with 3 case's might need you to look over it after I write it

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    The posted code still needs formatting. Do all the statements start in the first column in your editor?
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

    Phase 3. Develop a menu driven application that allows the user to add remove and list student objects from the arraylist developed

    Stuck now again on this part getting very confused.

    import java.util.*;
     
    public class StudentList3 {
     
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
     
    		ArrayList<StudentApp3> studentlist3 = new ArrayList<StudentApp3>();
            StudentApp3 nextStudent;
     
    		String fname;
    		String sname;
    		int grade;
    		int num = 3;
    		String Students;
     
    		Scanner kb  = new Scanner(System.in);
     
     
     
         Do While{
     
        	 case1 = Enter Students();{
        	 break;
        	 }
        	 case2 = List Students();{
        	 break;
        	 }
        	 case3 = Delete Students();{
        	 break;
        	 }
        	 case4 = Exit;{
        	 break;
        	 }	
         	}
     
     
     
    	public void EnterStudents();{
    		String addStudent;
     
    		{
                System.out.println("Add  Student");
    		}
    		}
     
    		for (int i=0; i < 3; i++){
     
    			System.out.println("Enter Firstname");
    			fname = kb.nextLine();
     
     
    			System.out.println("Enter Surname");
    			sname = kb.nextLine();
     
     
    			System.out.println("Enter Grade");
    			grade = kb.nextInt();
    			kb.nextLine();
     
     
    			nextStudent =  new StudentApp3 (fname,sname,grade);
    			studentlist3.add(nextStudent);
    		}
     
     
    	public void ListSTudents();
    		String ListStudents;
    		{
    		System.out.println("List Students");
    		kb.nextLine();
    		}
     
    		public void DeleteSTudents();
    		String ListStudents;
    		{
    			System.out.println("Delete Students");
    			kb.nextLine();
    			}
     
     
    		public void Exit();
    		String ListStudents;
    		{
    			System.out.println("Exit");
     
    			}
     
     
    		for (int j = 0;  j < 3;  j++){
     
    			System.out.println(studentlist3.get(j).toString());
     
     
    		}
     
    }			
     
     
     
     
    	}

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    Please explain where your problems are? If you are getting error messages, copy the full text and paste it here.


    Be sure to break the task up into small steps and work on one at a time.
    allows the user to
    That sounds like the code needs to ask the user a question and get a response.

    The formatting is still weird. Statements at the same logic level should start in the same column. Statements at an inner logic level should be indented.
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

    This is my do while plenty errors

     
     Do While{               ///Multiple markers at this line
    	                        - Do cannot be resolved to a type
    	                    - Syntax error, insert ";" to complete 
     
     
     
     
             case1 = Enter Students();{                      /// Multiple markers at this line
    	                                                               /// - case1 cannot be resolved to a variable
    	                                                               /// - The method Students() is undefined for the type 
    	                                                                ///   StudentList3
    	                                                                ///- Syntax error, insert ";" to complete BlockStatements
    	                                                               /// - Enter cannot be resolved to a variable
        	 break;
        	 }
        	 case2 = List Students();{
        	 break;
        	 }
        	 case3 = Delete Students();{
        	 break;
        	 }
        	 case4 = Exit;{
        	 break;
        	 }

    Methods for callen each case1

     
    public void EnterStudents();{                                                   ///  Multiple markers at this line
    	                                                  ///- Syntax error, insert "EnumBody" to complete BlockStatement
    	                                                  ///   - Syntax error, insert "enum Identifier" to complete 
    	                                                 ///EnumHeaderName
    	                                                  ///- Syntax error on token "void", @ expected
    		String addStudent;
     
    		{
    System.out.println("Add  Student");
    		}
    		}

    case2

    public void ListSTudents();
    		String ListStudents;
    		{
    		System.out.println("List Students");
    		kb.nextLine();
    		}

    case3
    public void DeleteSTudents();
    		String ListStudents;
    		{
    			System.out.println("Delete Students");
    			kb.nextLine();
    			}

    case4
    public void Exit();
    		String ListStudents;
    		{
    			System.out.println("Exit");
     
    			}

    Hope that is better.

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    Please copy the full text of the error message and paste it here. It has important info about the error.

    One problem I see is spelling errors. Java is case sensitive. Check the spelling of the keywords.
    Also there can not be spaces in the middle of a variable name.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

     
     Do While{               ///Multiple markers at this line
    	                        - Do cannot be resolved to a type
    	                    - Syntax error, insert ";" to complete 
     
     
     
     
             case1 = Enter Students();{                      /// Multiple markers at this line
    	                                                               /// - case1 cannot be resolved to a variable
    	                                                               /// - The method Students() is undefined for the type 
    	                                                                ///   StudentList3
    	                                                                ///- Syntax error, insert ";" to complete BlockStatements
    	                                                               /// - Enter cannot be resolved to a variable
        	 break;
        	 }
        	 case2 = List Students();{
        	 break;
        	 }
        	 case3 = Delete Students();{
        	 break;
        	 }
        	 case4 = Exit;{
        	 break;
        	 }


     
    public void EnterStudents();{                                                   ///  Multiple markers at this line
    	                                                  ///- Syntax error, insert "EnumBody" to complete BlockStatement
    	                                                  ///   - Syntax error, insert "enum Identifier" to complete 
    	                                                 ///EnumHeaderName
    	                                                  ///- Syntax error on token "void", @ expected
    		String addStudent;
     
    		{
    System.out.println("Add  Student");
    		}
    		}

    public void ListSTudents();                                                                                        
                                                      ///  Multiple markers at this line
    	                                                  ///- Syntax error, insert "EnumBody" to complete BlockStatement
    	                                                  ///   - Syntax error, insert "enum Identifier" to complete 
    	                                                 ///EnumHeaderName
    	                                                  ///- Syntax error on token "void", @ expected
    		String ListStudents;             
    		{
    		System.out.println("List Students");
    		kb.nextLine();
    		}

     
    public void DeleteStudents();                                                                                    ///  Multiple markers at this line
    	                                                  ///- Syntax error, insert "EnumBody" to complete BlockStatement
    	                                                  ///   - Syntax error, insert "enum Identifier" to complete 
    	                                                 ///EnumHeaderName
    	                                                  ///- Syntax error on token "void", @ expected
    		String ListStudents;
    		{
    			System.out.println("Delete Students");
    			kb.nextLine();
    			}

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    Do cannot be resolved to a type
    Did you see my last post about spelling?

    case1 cannot be resolved to a variable
    Where is the variable case1 defined?

    If you are trying to write a switch statement you need to go to a reference book to get the correct syntax for how to code a switch statement with its case statements.

    public void DeleteStudents();
    The ; is used to END a statement. The ; after the ) ends the definition for the method.

    Here is an example of a compiler's error message.
    The message should show the source with a ^ under the location of the error.
    Here is a sample from the javac compiler:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    If you don't understand my answer, don't ignore it, ask a question.

  21. #21
    Junior Member
    Join Date
    Oct 2013
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can any one tell me why I am getting an error

    Ok,am I far of track with what I am doing in the code,I find it hard but trying to do my best,what book would you think I should look at Norm.

  22. #22
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Can any one tell me why I am getting an error

    The Java Tutorials is almost always a good place to start.

  23. #23
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Can any one tell me why I am getting an error

    Get a couple of cheap used books to start with. Basic java is still the same as it was 5 years ago.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 4
    Last Post: October 15th, 2013, 04:33 AM
  2. Please! Help me to this error "ERROR CANNOT FIND SYMBOL"
    By mharck in forum Object Oriented Programming
    Replies: 8
    Last Post: July 3rd, 2012, 09:20 AM