PROGRAM NOT WORKING PLS TELL ME THE ERROR

0 smit patel · March 16, 2015
import java.util.scanner;

class apple {
public static void main(string args[]){
system.out.println("enter your name");
scanner s = new scanner(system.in);
system.out,print(s.nextline[]);


   }
}

Post a Reply

Replies

Oldest  Newest  Rating
+3 Branislav Lazic · March 16, 2015
And this is why we need "close" topic option.
+1 Umar ( ゚ヮ゚) · March 17, 2015
in your system.out,print(s.nextline[]);

you have a coma after out...

it should be System.out.print

another error I see in your code is that you are not putting key words CAPITAL

your scanner should be --> Scanner

your system should be --> System.out.println or System.out.print

your (string[]args) should be --> (String [] args);

I would suggest you to go back to Java Tutorial , and watch the video Hello Youtube
0 mitchell oldfield · March 17, 2015
You have tonnes of syntax errors mate.
0 smit patel · March 17, 2015
NOW WATS ERROR??

import java.util.Scanner;

class apples {
public static void main(String args [] ){
System.out.println("enter your name");
Scanner a = new Scanner(System.in);
System.out.print(a);

  }
}
+1 Umar ( ゚ヮ゚) · March 17, 2015
Hello Again from eye balling your code it looks like you're trying to print out users first name?

Your code: 

import java.util.Scanner;

class apples {
public static void main(String args [] ){
System.out.println("enter your name");
Scanner a = new Scanner(System.in);
System.out.print(a);

}
}



You need to remember when you want the user to input there name it is a String
so you need to add a String variable to store the users name

Code edited: 


  1. import java.util.Scanner;

  2. public class apples {             

  3. public static void main (String[]args) { 

  4. Scanner a = new Scanner (System.in);

  5. String FirstName;

  6. System.out.println ("Please Enter your First Name : " );

  7. FirstName = a.nextLine();

  8. System.out.println("Your First Name is : " + FirstName);

  9. }

  10. }




Line 5: created a String FirstName to hold the Users First name
Line 6: asking the user to enter there first name
Line 7: This will allow the user to enter there First name
Line 8: will print out "Your first name is" and  concatenate what the user input as there name


 
0 smit patel · March 19, 2015
thank u again
+1 Umar ( ゚ヮ゚) · March 19, 2015
No Problem! :) 
  • 1

Java / Android Development

107,299 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator