Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:55:37+00:00 2026-05-26T16:55:37+00:00

public class Test{ public static void main(String[] arg){ System.out.println(Alexander The Great); } } In

  • 0
public class Test{
    public static void main(String[] arg){
        System.out.println("Alexander The Great");
    }
}

In this code, if I remove the first quotation mark in the string, I get 3 errors.
1. ‘)’ expected
2. unclosed string literal
3. not a statement

ok, I understood above errors.

If I remove the second quotation mark in the string, I also get 3 errors.
1. unclosed string literal
2. ‘;’ expected
3. reached end of file while parsing

I understood 1 and 2, but why 3??

Doesn’t it usually occur when braces are missing? But clearly, I have correct number of braces.
Also, why not the first case give the error “reached end of file while parsing”?

P.S. I’m using jGrasp, java 1.6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:55:38+00:00Added an answer on May 26, 2026 at 4:55 pm

    Leaving off the first quote potentially gives the parser a bit more to work with, because it will try to treat “Alexander” as a reference. Once it hits the space, the only legal stuff is the rest of an expression, but instead it thinks it’s another identifier.

    It may be inserting a bonus ) to try to recover; depends on the implementation.

    Leaving off the last quote will send the parser to the end of the line. Instead of trying to close off that statement, it gets a little lost and spins off and can’t recover and hits the end of the file.

    Off the top of my head, to me it seems that since Java strings are single-line only, it could do much the same thing and try to close off the string and/or statement in that case and recover a bit more gracefully. I might just be missing something obvious, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code public class TEST { public static void main(String arg[]){ try
Take a look at this code: public class Test { public static void main(String...
I have written this piece of code public class Test{ public static void main(String[]
I have this piece of code: class Test { public static void main (String[]
public class Test extends Thread{ public void hello(String s){ System.out.println(s); } public void run(){
Code: public class Test { public static void main(String[] args) { String str =
In the following code public class Test { public static void main(String[] args){ int
I have this class: public class Test { public static void main(String[] args) {
Consider this example : import java.lang.reflect.Field; public class Test { public static void main(String[]
I'd a code snippet: public class Test{ public static void main(String args[]){ Integer a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.