Hi,

On May 12, 8:41 pm, chetan <[email protected]> wrote:
> I am creating the project MyOwnProject for 1014 homework. I cannot
> find out what is wrong in this code.
> displays error. package sr1 does not exist and also identifier
> expected. If i remove the function and static variable studentId.
> things become ok>>>
>
> public class Student {
>
>     /**
>      * @param args the command line arguments
>      */
>
>     public static void main(String args[])
>     {
>         // TODO code application logic here
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>         public static int studentId=0;
>         public void setStudentId(int id){
>             studentId =id;
>         }
>         public int getStudentId()
>         {
>             return studentId;
>         }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This section of code is in the main-Method of your class!!!

Put it into the Class and outside of the main methode.


>         //making three instances of student recod class
>         StudentRecord sr1=new StudentRecord();
>         StudentRecord sr2=new StudentRecord();
>         StudentRecord sr3=new StudentRecord();
>         //set the names of student & increasing the count
>
>         sr1.setName("Amit");
>         StudentRecord.increaseStudentCount();
>
>         sr2.setName("Navneet");
>         StudentRecord.increaseStudentCount();
>
>         sr3.setName("Happy");
>         StudentRecord.increaseStudentCount();
> //displaying the name
>        System.out.println(sr1.getName());
>         System.out.println(sr2.getName());
>         System.out.println(sr3.getName());
>
>     }
>
> }
>
>
HTH Ewald

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to