Friday 15 April 2011

java - whats wrong with this code? -


For some reasons I keep anything blank which I keep in empty lines, I try to create a program I'm reading the input, removes all the unnecessary white spaces but a place between each word. Then print all the lines

  import java.util.Scanner;  

Do not use any sentinels to close. Import java.lang.Character; Import java.lang.String; Public class trim {public static zero main (string [] args) {string namename = ""; String sound = ""; Int i = 0; Int count = 0; Scanner scan = new scanner (System.in); While (scan.hasNextLine ()) {count ++; Scan.nextLine (); }; (; I

  while (scan.hasNextLine ()) {count ++; Scan.nextLine (); }   

This will also read all the inputs before your program actually starts.

After that (if the program also goes away, STDIN usually does not lock on the console) There is nothing else to read in the second loop in the scan.

In addition, the names of lower-case class are confused as upper-case variable names. At least you are consistent here; -)

No comments:

Post a Comment