• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

cant get program to complile

cant get program to complile, what is im doing wrong?

import java.util.*;
public class palindrome
{

public static void main(String args[]) throws IOException
{
int palindrome_number=0;
System.out.println("Please input a 5-digit number");
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String line = input.readLine();
boolean palindrome = line.equalsIgnoreCase(new StringBuffer(line).reverse().toString());
if (palindrome)
{
System.out.println("it is a palindrome");
}
else
{
System.out.println("it is not a palindrome");
}
}
 
 
error2.JPG
0
waltbaby315
Asked:
waltbaby315
1 Solution
 
for_yanCommented:
You need to add at least one "}" in the end
0
 
objectsCommented:
missing a brace


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class palindrome {

	public static void main(String args[]) throws IOException {
		int palindrome_number = 0;
		System.out.println("Please input a 5-digit number");
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String line = input.readLine();
		boolean palindrome = line.equalsIgnoreCase(new StringBuffer(line).reverse().toString());
		if (palindrome) {
			System.out.println("it is a palindrome");
		} else {
			System.out.println("it is not a palindrome");
		}
	}
}

Open in new window

0
 
for_yanCommented:
Yes, you need to add one "}" to close the class itself.
0
 
msk_apkCommented:
you missed one } which started at public class {
0
 
sweetfa2Commented:
The class itself needs to be closed off.

Sometimes by using indenting at each brace point you will find it easier to detect issues such as this.

Generally when you get an error message that says reached end of file prematurely it means that a syntactic element has been started, but no matching ending element has been discovered.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now