Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

Where to use curly brackets in Java 1 Class public class MyClass attributes and methods 2 Method public static void main String args method code 3 If other Java code if

VIEWS: 61 PAGES: 2

									Where to use curly brackets in Java
1. Class public class MyClass { // attributes and methods }

2. Method public static void main(String [] args) { // method code }

3. If // other Java code if(test_condition) { // code to run if test evaluates to true }

4. If-Else // other Java code if(test_condition) { // code to run if test evaluates to true } else { // code to run if test evaluates to false }

5. For // other Java code for(int loop = 0; loop < maxLoop; loop++) { // code to loop through }

6. While // other Java code while(test_condition) { // code to execute whilst test_condition remains true }

7. Do-While // other Java code do { // code to execute whilst test_condition remains true } while(test_condition);

8. Switch // other Java code switch(value) { // case statements }


								
To top