13 Replies - 3847 Views - Last Post: 12 June 2011 - 07:24 PM Rate Topic: -----

#1 mikejsr51  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 36
  • Joined: 17-January 11

Java error -- reached end of file while parsing

Posted 12 June 2011 - 02:33 PM

public class TryExample1_1 {

  public static void main(String[] args) {

    byte value = 1;

    for (int i=0; i<7 ; i++) {

      value*=2;

      System.out.println("Value is now " + value);

    }

  }


Receiving 1 error Tool completed with exit code 1.

Can you help?

Is This A Good Question/Topic? 0
  • +

Replies To: Java error -- reached end of file while parsing

#2 smohd  Icon User is online

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 02:37 PM

Yes you need to close your class. You missed one "}"
Was This Post Helpful? 0
  • +
  • -

#3 mikejsr51  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 36
  • Joined: 17-January 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 02:55 PM

I've tried to add, take away. Don't see where it's missing from. Can you help?
Was This Post Helpful? 0
  • +
  • -

#4 smohd  Icon User is online

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 02:59 PM

Look you have opened three times, one for class, one for main and one for the for loop but you closed only two! So add another "}" at the end of your code
Was This Post Helpful? 0
  • +
  • -

#5 umcsdon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 26-May 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 03:00 PM

You missed one "}" at the end. Try add one.
Was This Post Helpful? 0
  • +
  • -

#6 mikejsr51  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 36
  • Joined: 17-January 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 03:03 PM

View Postsmohd, on 12 June 2011 - 02:37 PM, said:

Yes you need to close your class. You missed one "}"

I don't see where it's missing from. This is what I have for the class: public class TryExample1_1 {

Can you show me where it's missing from?

Was This Post Helpful? -2
  • +
  • -

#7 umcsdon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 26-May 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 03:27 PM

View Postmikejsr51, on 12 June 2011 - 02:33 PM, said:

public class TryExample1_1 {

  public static void main(String[] args) {

    byte value = 1;

    for (int i=0; i<7 ; i++) {

      value*=2;

      System.out.println("Value is now " + value);

    }

  }

 }


look at the last line.
Was This Post Helpful? 0
  • +
  • -

#8 mikejsr51  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 36
  • Joined: 17-January 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 05:09 PM

Wasn't sure the first one went through.

View Postumcsdon, on 12 June 2011 - 03:27 PM, said:

View Postmikejsr51, on 12 June 2011 - 02:33 PM, said:

public class TryExample1_1 {

  public static void main(String[] args) {

    byte value = 1;

    for (int i=0; i<7 ; i++) {

      value*=2;

      System.out.println("Value is now " + value);

    }

  }

 }


look at the last line.

The book this came from did not have three braces. It only had two. How can you determine that?

What determines the amount of braces in a small program like this?

Does reached the end of file while parsing always mean that there is a brace missing?
Was This Post Helpful? 1
  • +
  • -

#9 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1390
  • View blog
  • Posts: 3,071
  • Joined: 05-April 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 05:11 PM

View Postmikejsr51, on 12 June 2011 - 05:07 PM, said:

Wasn't sure the first one went through.

View Postumcsdon, on 12 June 2011 - 03:27 PM, said:

View Postmikejsr51, on 12 June 2011 - 02:33 PM, said:



look at the last line.

The book this came from did not have three braces. It only had two. How can you determine that?

What determines the amount of braces in a small program like this?


I gave your post + rep again. I got confused about your post because you wrote INSIDE the quote tags.

You always need to have equally amounts of { and } symbols. the start { in your class declaration tells that this is where the class starts and the end } tells that this is where the class ends. So everything in between them is a part of the class. The same can be said about the for-loop
Was This Post Helpful? 0
  • +
  • -

#10 mikejsr51  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 36
  • Joined: 17-January 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 05:12 PM

View Postumcsdon, on 12 June 2011 - 03:00 PM, said:

You missed one "}" at the end. Try add one.

Yes this was very helpful! I appreciate your help!
Was This Post Helpful? 0
  • +
  • -

#11 smohd  Icon User is online

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 05:18 PM

View Postmikejsr51, on 13 June 2011 - 05:54 AM, said:

What determines the amount of braces in a small program like this?

Does reached the end of file while parsing always mean that there is a brace missing?


Yes, most of the time it means closing one is missing. When you have done many exercise and got many errors you become familiar with error messages that you can understand what the error message means
Was This Post Helpful? 0
  • +
  • -

#12 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,025
  • Joined: 15-July 08

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 05:23 PM

Every opening { has to have a } at the end of the section.
Was This Post Helpful? 0
  • +
  • -

#13 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 06:00 PM

indent your code properly the unbalnace {} will become obvious

and :code: does not mean each line of code but a block of them :)

public class TryExample1_1 {
	public static void main(String[] args) {
		byte value = 1;
		for (int i=0; i<7 ; i++) {
			value*=2;
			System.out.println("Value is now " + value);
		}
	}
}



Was This Post Helpful? 0
  • +
  • -

#14 mikejsr51  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 36
  • Joined: 17-January 11

Re: Java error -- reached end of file while parsing

Posted 12 June 2011 - 07:24 PM

View Postpbl, on 12 June 2011 - 06:00 PM, said:

indent your code properly the unbalnace {} will become obvious

and :code: does not mean each line of code but a block of them :)

public class TryExample1_1 {
	public static void main(String[] args) {
		byte value = 1;
		for (int i=0; i<7 ; i++) {
			value*=2;
			System.out.println("Value is now " + value);
		}
	}
}




Thank you so much! This was very helpful!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1