• Register
1 vote
27 views

Problem:

Hello Kodlogs,
I’ve written my very first program in java that is supposed to print Hello World. But for some reason, it is not displaying my expected line. It is showing error reached end of the line while parsing. Find my java program below and please, figure out the error.

public class HelloWorld{
     public static void main(String []args){
        System.out.println("Hello World");
     }

Many thanks guys. I really appriciate your effort.

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution:

You just missed a curly brace end of your program. Close the brace of your public class end of the program and give it another try. 

public class HelloWorld{
     public static void main(String []args){
        System.out.println("Hello World");
     }
}

Now, your program should compile and print your expected things.

Note: Always put the opening and closing braces at the same time and put the code inside it. This is the best practice.

13 9 6
94,240 points

Related questions

0 votes
1 answer 9 views
9 views
problem;I keep getting the error: reached end of file while parsing. I can't figure out what is wrong.
asked Feb 7 kaash_kashi 1.2k points
0 votes
1 answer 12 views
12 views
What am I doing wrong? Any help appreciated.
asked Dec 30, 2020 TeamScript 13.5k points
0 votes
1 answer 3 views
3 views
Problem: I have the following source code public class mod_MyMod extends BaseMod public String Version() { return "1.2_02"; } public void AddRecipes(CraftingManager recipes) { recipes.addRecipe(new ItemStack(Item.diamond), new Object[] { "#", Character.valueOf('#'), Block. ... it I get the following error: java:11: reached end of file while parsing } What am I doing wrong? Any help appreciated.
asked Feb 18 Ali 4.4k points
0 votes
1 answer 4 views
4 views
Problem: reached end of file while parsing in java
asked 3 days ago Hira 2.2k points
1 vote
1 answer 18 views
18 views
Problem: I have the following source code below: package com.gavin; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World !"); } This code returns me an error “reached end of file while parsing java” What could be a possible solution in my case?
asked Mar 7, 2020 Gavin 15.3k points
1 vote
1 answer 252 views
252 views
Problem: Hello all, I am a new, college student who is learning python programming. I am thinking to write a program that will input a text file and read all the vowels from it and determines when it comes to the end of the file. So, is it possible to create a while loop that determines when the end of a file has been reached? Thanks in advance.
asked Mar 16, 2020 Gavin 15.3k points
0 votes
1 answer 5 views
5 views
Problem npm err! unexpected end of json input while parsing near.
asked 2 days ago Dan phillip 1.9k points
0 votes
1 answer 7 views
7 views
Probelm: unexpected end of file while looking for precompiled header
asked Feb 17 Dan phillip 1.9k points
0 votes
1 answer 13 views
13 views
Why doesn't ifstream.eof() return TRUE after reading the last line of the file? When a beginner starts reading an ifstream, the instinct is usually to read the file using a loop like this: while (!ifstream.eof() { ... } However, when I used this code I noticed that ... file is better off using a loop like this: while (ifstream >> someVar) { ... } Why is the first code not always working properly?
asked Aug 29, 2020 sasha 12.9k points
0 votes
1 answer 5 views
5 views
Problem: I wrote some simple code in Java, the method should connect to the website and return the BufferedReader. private BufferedReader getConnection(String url_a) { URL url; try { System.out.println("getting connection"); url = new URL(url_a); HttpURLConnection urlConnection = (HttpURLConnection) ... When I use it on my PC, it works fine but when I put .jar file on the server I get this error:
asked Feb 18 Ali 4.4k points