Link to home
Start Free TrialLog in
Avatar of waltbaby315
waltbaby315

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick Barry
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

Yes, you need to add one "}" to close the class itself.
you missed one } which started at public class {
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.