I'm having quite a few errors on this one. This is my first attempt on "free" coding outside tutorials. I do believe it only has to do with bad use of brackets from my side, but i'm a beginner.
Line 14 - Illegal start of expression
Line 18 - Class, interface or enum expected
Line 21 - Class, interface or enum expected

public class Class_z {
public static void main(String[]args){

int c = 5;
int d = 10;

int answer = true1(99);

if(c >= d){
static int true1(int a){
return a;
else {

5 Years
Discussion Span
Last Post by JamesCherrill

Lines 13-15 look like a method definition, but they are right in the middle of an if inside another method. That has baffled the compiler and is the source of all three errors. Remember you can only define a method inside a class but outside any other method definitons. (OK, not exactly true, but we can talk about anonymous inner classes another time.)
You will find it much easier to get your brackets right if you indent your code (or use an editor that does it for you).

ps Welcome to DaniWeb! Please take a moment to check the site rules, and please mark your threads "solved" when you have finished.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.