Results 1 to 9 of 9
Thread: Help with input class
- 02-05-2011, 01:15 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Help with input class
Hi,
I'm extremely new to java and I'm struggling to understand the role 'class' and 'input'
could someone please explain?
also i tried to compile a basic example program using javac on terminal and it displayed the error message,
Untitled-1.java:6: class input is public, should be declared in a file named input.java
public class input{
^
1 error
what does this mean?
thank you for any help
- 02-05-2011, 01:26 AM #2
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
class is a keyword, for explanation here is a java tutorial What Is a Class? (The Java™ Tutorials > Learning the Java Language > Object-Oriented Programming Concepts)
in your code input is the name of your class and your file as well.
the error is telling you that the name of your class (which is input) is not the same with the name of the file itself, it should be save as input.java
- 02-05-2011, 01:53 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Thanks!
Next problem, when i run the program the console says "exception in thread 'main' "
any advice?
- 02-05-2011, 01:56 AM #4
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Show your code and have you tried to search this on google. Im pretty sure lots of result will show.
- 02-05-2011, 02:18 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
5/02/11 1:14:08 PM [0x0-0x35035].com.apple.JarLauncher[570] Exception in thread "main" java.util.NoSuchElementException: No line found
5/02/11 1:14:08 PM [0x0-0x35035].com.apple.JarLauncher[570] at java.util.Scanner.nextLine(Scanner.java:1516)
5/02/11 1:14:08 PM [0x0-0x35035].com.apple.JarLauncher[570] at input.main(input.java:15)
- 02-05-2011, 02:48 AM #6
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
We cannot tell you where is the error with just the error message we need the source code, your code.
- 02-05-2011, 03:13 AM #7
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
import java.util.*;
import java.io.*;
public class input{
public static void main(String args[])
{
Scanner read = new Scanner(System.in);
boolean run = true;
String data = "";
do{
System.out.println("\nLogging Keystrokes...");
data = read.nextLine();
System.out.println(data);
}while(run);
}}
-
I am not getting your errors when compiling or running your code.
- 02-05-2011, 04:27 AM #9
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Keyboard Input In A Seperate Class?
By FatalSylence in forum New To JavaReplies: 6Last Post: 10-12-2010, 05:29 AM -
How to read user input in hh:mm:ss without time class
By lbayne in forum New To JavaReplies: 1Last Post: 09-30-2010, 02:36 AM -
Input output without string class
By surenq1 in forum New To JavaReplies: 4Last Post: 06-13-2010, 03:18 PM -
Is there any other class for input in command prompt? Please help.
By MarkSquall in forum Advanced JavaReplies: 8Last Post: 06-27-2009, 05:35 PM -
how to take input and verify input in Java programs
By bilal_ali_java in forum Advanced JavaReplies: 0Last Post: 07-21-2007, 08:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks