Results 1 to 2 of 2
Thread: java error
- 03-14-2012, 11:07 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 1
- Rep Power
- 0
java error
hi ,
i have copied a java code to read random numbers from txt file
but i keep getting an error after defining the arroy (Error : Syntax error on token ";",[Expected after this token])
Java Code:public class random { FileInputStream in = new FileInputStream("tall.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; String[] myarray; myarray = new String[10]; while ((strLine = br.readLine()) != null) { for (int j = 0; j < myarray.length; j++){ myarray[j] = br.readLine(); } } in.close(); }}
-
Re: java error
You probably shouldn't copy code but instead copy ideas found in code, and write your own code. If you did this you'd likely first create a method, such as a main method, and place your code in it. Right now you've got code that belongs in a method or constructor sitting out naked in the class, and this will never work.
Similar Threads
-
' error: cannot read: Welcome.java 1 error ' compiling on Java for Mac, HELP!
By exeye0h in forum New To JavaReplies: 16Last Post: 01-11-2012, 02:45 PM -
java.sql.SQLException: System or internal error java.io.IOException: Stream closed
By ashok bhagat in forum Advanced JavaReplies: 0Last Post: 01-21-2011, 12:43 PM -
java out of memory error-heap space error
By elsanthosh in forum NetBeansReplies: 4Last Post: 06-15-2010, 09:31 AM -
Thread: Error 500--Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12-05-2009, 07:28 AM -
java.lang.Error: Error opening DSound for capture
By NARs in forum NetworkingReplies: 1Last Post: 10-26-2009, 04:38 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks