- 1

Java types of methods,functions,statements

Can anyone give me an example what order the above go or an easy way to remeber when {} and () are used. thanks

14th Jun 2017, 1:02 PM
D_Stark
D_Stark - avatar
2 Antworten
+ 3
public void add() { //statements } () used as arguments both when defining a method and when calling a method. can be empty add() or have arguments add(int x, int y) .. If it is empty it is simply called with add() .. If it has arguments it is called with arguments add(1,2) {} basically a block. when you have a method and block it in as I did above it tells the method where to start and where to stop. Used for all types of blocks such as if/else statements, try and catch statements, switch statements, etc. if(something){ //Do something } else { //Do something }
14th Jun 2017, 1:15 PM
LordHill
LordHill - avatar
+ 1
yaar it is very easy to understand. {} used for implement anything within this bracket. () used for function method() example void m1() { some implementation here } very simple.. my opinion is you first see very basic points of java like variable how can declare, how can use it. then data types, what is it, how can use for, that is class, why need it. what is method etc
14th Jun 2017, 6:08 PM
meherDev
meherDev - avatar