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 3 of 3

Thread: newbie: Getting started with java, need help on this

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up 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:
    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?
    system.out.println(getPerson.name)
    ?

    I have only taken two classes of java yet, sorry for this noob question.
    Thanks for reading.


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: newbie: Getting started with java, need help on this

    This thread has been cross posted here:

    http://www.java-forums.org/new-java/46688-newbie-getting-started-java-need-help.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting

    Improving the world one idiot at a time!

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default 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.

    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
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Newbie Java Question
    By tinkersp in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 23rd, 2011, 01:41 PM
  2. Newbie: seem confused with Java
    By boyscout in forum Java Theory & Questions
    Replies: 1
    Last Post: April 8th, 2011, 09:12 AM
  3. hello~ i am newbie here and to java
    By puyunk in forum Member Introductions
    Replies: 1
    Last Post: March 4th, 2011, 06:57 AM
  4. java newbie help..
    By robin28 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 30th, 2010, 05:54 AM
  5. Java newbie...Help required
    By muraduk in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 12th, 2010, 03:15 PM