Results 1 to 3 of 3
Thread: 2 errors with Scanner , help
- 01-24-2009, 08:50 PM #1
Member
- Join Date
- Jan 2009
- Posts
- 3
- Rep Power
- 0
2 errors with Scanner , help
hi,
im anew member >> can u help me please
i have 2 errors with this code
The errors in the 5th line
Java Code:public class wordlength { public wordlength() { } public static void main(String[] args) { // the errors are in the next line Scanner stdin = Scanner.create (System.in); System.out.print("Enter Word"); String word = stdin.nextline(); int wordlength = word.length(); System.out.println("word"+word+"has length"+wordlength+"."); }}
- 01-24-2009, 09:22 PM #2
Member
- Join Date
- Jan 2009
- Posts
- 6
- Rep Power
- 0
import java.util.Scanner;
public class wordlength {
public wordlength() {
}
public static void main(String[] args) {
// the errors are in the next line
Scanner stdin = new Scanner(System.in);
System.out.print("Enter Word");
String word = stdin.nextLine();
int wordlength = word.length();
System.out.println("word"+word+"has length"+wordlength+".");
}}
- 01-24-2009, 09:34 PM #3
Member
- Join Date
- Jan 2009
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
2 errors with Scanner , help
By enghar in forum New To JavaReplies: 3Last Post: 01-25-2009, 03:03 AM -
makeButton errors
By ljk8950 in forum AWT / SwingReplies: 12Last Post: 08-10-2008, 01:10 AM -
help with these errors
By oceansdepth in forum New To JavaReplies: 3Last Post: 04-16-2008, 04:55 PM -
Errors I don't understand
By MattyB in forum New To JavaReplies: 4Last Post: 04-01-2008, 11:55 PM -
Errors in constructor
By ai_2007 in forum Advanced JavaReplies: 0Last Post: 07-01-2007, 05:35 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks