[java] im using eclipse luna and it auto terminates as soon as it starts it just terminates?
import java.util.Scanner;
public class data {
public static void main(String args[]){
Scanner input = new Scanner (System.in);
}
}
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.
[java] im using eclipse luna and it auto terminates as soon as it starts it just terminates?
import java.util.Scanner;
public class data {
public static void main(String args[]){
Scanner input = new Scanner (System.in);
}
}
What would you expect it to do?
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!
I was just gonna make something where you type in a word and it tells you what it means but all im trying to do is test the scanner and it doesn't even do that
How are you testing a Scanner?
All this code does is create a Scanner. You don't actually tell the Scanner to do anything, and you don't print anything to the console, which is why you don't see anything when the program executes.
Try adding a simple print statement at the very end of your main() method, that way you at least know it's running.
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!
the text appears but it just skips right over the scanner and prints it
import java.util.Scanner;
public class data {
public static void main(String args[]){
Scanner input = new Scanner (System.in);
System.out.println("hello world");
}
}
Scanner is just an object. You haven't called any of its methods to have it do anything.
ive used this line before and it let me type in but its not this time literally just Scanner input = new Scanner(system.in); and it let me type in
Try something like
String s= input.next(); System.out.println(s);
after your hello world print statement
Check out the API http://docs.oracle.com/javase/7/docs...l/Scanner.html
blockmaster2001 (October 1st, 2014)
that's incredible thanks jbarke12