newbie: Getting started with java, need help on this
Hello,
so basically i am getting started with java.. I am doing work on eclipse, i am making a library project as a sample..
The library project includes the class of person and books..
here is my sample class of person:
Code Java:
package Library;
public class person {
private String name;
private int maxBooks;
public person(){
name = "unknown name";
maxBooks = 0;
}
public String getName(){
return name;
}
public int getMaxBooks() {
return maxBooks;
}
public void setMaxBooks(int maxBooks) {
this.maxBooks = maxBooks;
}
public void setName(String name) {
this.name = name;
}
}
I have done this, but now i need code by which a user will enter his maxBooks and Name, and also a code that will output name and maximum books of the person, it may be like this?
Quote:
system.out.println(getPerson.name)
?
I have only taken two classes of java yet, sorry for this noob question.
Thanks for reading.
Re: newbie: Getting started with java, need help on this
Re: newbie: Getting started with java, need help on this
Please see - http://www.javaprogrammingforums.com...ner-class.html
As an example, you can add this to your person class.
Code Java:
public static void main(String[] args){
person p = new person();
p.name = "Johnny Bravo";
System.out.println(p.getName());
}
When compiled, the output will be Johnny Bravo