My first Java program
int id;
String name;
Student1(int i,String n){
id=i;
name=n;}
public String getName(String n)
{return name;}
public static void main(String args[]){
Student1 s1=new Student1(3,"Sergiu");
System.out.println(s1.getName(""));
}
}
This is what came out after dozens of tries trying to learn about the syntax, constructors and getters. How would you do the program in a simpler way?
The goal is to define a Student object in main and to output one of its parameters.
PS: I'm ready to become a programmer, guys!
-
JMondaCom -
Thanks
{{ DiscussionBoard.errors[10792769].message }} -
-
minirich -
Thanks
{{ DiscussionBoard.errors[10815772].message }} -