Code end question

/* Hello. I dont understand why this code doesnt work if i remove the las two }… After all there should be only one at the beggining and the end of the code but what are the other two } for? */

public class If {
public static void main(String args) {

	if (1==1) {

		System.out.println("Access granted.");

	}
	
}

}

Count the braces… Three of each so yes, the last two are needed.

class {

}

method () {

}

conditional () {

}

All have necessary block containment.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.