Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By Fubarable

Thread: java error

  1. #1
    meriam is offline Member
    Join Date
    Mar 2012
    Rep Power

    Question 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();

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default 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.
    DarrylBurke likes this.

Similar Threads

  1. Replies: 16
    Last Post: 01-11-2012, 03:45 PM
  2. Replies: 0
    Last Post: 01-21-2011, 01:43 PM
  3. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  4. Replies: 1
    Last Post: 12-05-2009, 08:28 AM
  5. Replies: 1
    Last Post: 10-26-2009, 05:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts