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

Thread: hey i need some help with the main of this methods that i made pls help

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hey i need some help with the main of this methods that i made pls help

    Hey guys Sory for disturbing i need some help about an exampe that i made if you can help me up i need hel with main for this example:
    =============>public class Student {

    private String name = " ";
    private String course = " ";

    public Student (String studentName, String studentCourse)
    {
    name = studentName;
    course = studentCourse;
    }

    public String getName ( )
    {
    return name;
    }

    public void setName (String studentName)
    {
    name = studentName;
    }

    public String getCourse ( )
    {
    return course;
    }

    public void setCourse (String studentCourse)
    {
    course = studentCourse;
    }
    }
    What it was asked me to do is to make e program in java with a class called Student with to methods one that set the name of student and the other the returns it so i made those methods but i need hel in the main can you help plssss is very important for me at the school thnnxxx i'm waitin for you answers


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: hey i need some help with the main of this methods that i made pls help

    So, is it that you don't know how to create a main? Or that you don't know how to create a Student Object in your main? Or, what?

    Also, please wrap your code in tags so it is more legible.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: hey i need some help with the main of this methods that i made pls help

    Please don't post questions in the member introductions forum: http://www.javaprogrammingforums.com...e-posting.html

    Please use the highlight tag when posting code.

    Please use proper spelling and grammar. Read the link in my signature on asking questions the smart way. Also included in that article is why it's a bad idea to include notes about your urgent deadline.

    Please ask a specific technical question. Saying "i need hel in the main" is not very useful to us.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: hey i need some help with the main of this methods that i made pls help

    Right now you're not really using the setter methods.

    Your code in the constructor is doing the setting code as well for you. However, maybe you're supposed to do it that way.

    As for main, do this

     
    public static void main(String[] args)
    {
     
    java.util.Scanner console = new java.util.Scanner(System.in);
     
    // Use next() or nextLine() methods with Scanner object to read in the name and course from the user.  (Or you could just initialize them yourself like below.)
     
    Student s = new Student("Abraham Lincoln", "History 101");
     
     
     
     
    }
    Last edited by javapenguin; May 14th, 2012 at 12:43 PM.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: hey i need some help with the main of this methods that i made pls help

    Cross posted at Re: executing a method in main class
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Let's Bounce! (game I made for LD warmup weekend)
    By KevinWorkman in forum The Cafe
    Replies: 7
    Last Post: April 17th, 2012, 08:00 AM
  2. changes made to JSP or servlets
    By the light in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: May 30th, 2011, 08:19 AM
  3. Bigger triangle made up of multiple ones?
    By Kimimaru in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 30th, 2011, 11:18 AM
  4. Databases in Java made Easy with JPersist
    By Lord.Quackstar in forum JDBC and Database Tutorials
    Replies: 1
    Last Post: June 14th, 2010, 06:38 AM
  5. Databases in Java made Easy with JPersist
    By Lord.Quackstar in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: June 14th, 2010, 06:38 AM