Results 1 to 3 of 3
  1. #1
    Bigheart is offline Member
    Join Date
    Aug 2016
    Posts
    1
    Rep Power
    0

    Default Very new to java

    im getting some errors with my coded, and i dont know what ive done wrong. any help is appreciated. This is the error im receiving

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    The method nextline() is undefined for the type Scanner

    at GettingStarted.main(GettingStarted.java:27)

    =================================================

    import java.util.Scanner;


    public class GettingStarted{

    // The main method of the class. Program execution starts here.
    public static void main(String[] args){




    System.out.println("Program 1 by Michael Bigheart" );
    Scanner scan = new Scanner(System.in);
    System.out.println(" What is your name?");
    String name = scan.nextline();
    System.out.println (" What is your major?");
    String major = scan.nextLine();
    System.out.println(" How old are you?");
    Double age = scan.nextDouble();
    System.out.println("\n"+" name "+" is majoring in "+" major "+ ",");
    System.out.println("and is "+ "age" + "years old");
    System.out.println("Hello World!");

    }//End of main method
    } // End of Program1 class

  2. #2
    ShadowWalker is offline Senior Member
    Join Date
    Mar 2013
    Location
    Greece
    Posts
    183
    Rep Power
    8

    Default Re: Very new to java

    If you want my advice, when you face these kind of problems go to the line that error message tells you delete the line, then think what you want to do and write it back again. If you do, you will see that you misspelled the method nextLine() with nextline(). Remember Java language is a case sensitive.

  3. #3
    tanzeelNiazi is offline Member
    Join Date
    Aug 2016
    Posts
    4
    Rep Power
    0

    Default Re: Very new to java

    it is
    Java Code:
    String name = scan.nextLine();
    not
    Java Code:
    String name = scan.nextline();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •