Scoping and Variablelength Arruguments
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World");
int b = 200;
sum();
}
static void sum(){
int a = 100;
System.out.println(a);
}
}
function scoping jasa ya sum() wala method ka under hum b ko access nahi kar sakta because wo function scope ka bahar haa sum(){ }
Block level scope { }
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World")
{
int c = 100;
}
System.out.println(c);
}
}
asa karana ga toa error aya ga because hum block ka bhar c ko print karwana ke koshis kar raha haa
error will be symbol not found
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World");
String a = "bip";
{
a = "soniya";
}
System.out.println(a);
}
}
bus kuch nahi hum refrence ko update karwa deraha haa
100 200 100
because block level mea hiher wala hide ho jata haa iseko shadowing khata haa
Variablel length Arguments
multiple argument is also possible
Comments
Post a Comment