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: JAVA Programmer Beginner

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA Programmer Beginner

    Hello,

    I'm new to JAVA Programming and I need help. I'm using Eclipse as my IDE and I wrote a program:

    package org.babynamecomparison.java;

    import java.util.Scanner;

    public class BabyNameComparison {
    public static void manin(String[] args){
    Scanner userInputScanner = new Scanner(System.in);
    System.out.print("Enter 1st FirstName");
    String name1 = userInputScanner.nextLine();
    System.out.print("Enter 2nd First Name");
    String name2 = userInputScanner.nextLine();
    System.out.print("Enter 3rd First Name");
    String name3 = userInputScanner.nextLine();

    System.out.println(name1 + "" + name2);
    System.out.println(name1 + "" + name3);
    System.out.println(name2 + "" + name1);
    System.out.println(name2 + "" + name3);
    System.out.println(name2 + "" + name1);
    System.out.println(name3 + "" + name2);
    }
    }

    When I try to run it, it says "The selection cannot be launched, and there are no recent launches."
    I do get a warning that says, "Resource leak: 'userInputScanner' is never closed". What am I doing wrong?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: JAVA Programmer Beginner

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

    Check the spelling of 'main'.

  3. #3
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: JAVA Programmer Beginner

    You can ignore the 'resource leak' warning, or you can silence it by "closing"
    the Scanner object with the method close() after your input instance of Scanner.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

Similar Threads

  1. Would appreciate help (Beginner programmer)
    By TSSF44 in forum Java Theory & Questions
    Replies: 5
    Last Post: October 18th, 2013, 04:39 AM
  2. Hello Community - Beginner Java Programmer
    By Dream Hacked in forum Member Introductions
    Replies: 1
    Last Post: July 25th, 2013, 04:12 PM
  3. tips for beginner programmer
    By Syahdeini in forum The Cafe
    Replies: 1
    Last Post: July 11th, 2012, 09:31 PM
  4. beginner programmer trouble
    By scottey313 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 30th, 2011, 01:41 PM
  5. Beginner java programmer!
    By chrisivey1980 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: April 23rd, 2011, 03:06 AM