Hi,
I have two questions regarding the examples taken from Marcus Green tutorial.
Re #1:
public class MyIf{
public static void main(
String argv[]){
MyIf mi = new MyIf();
}
MyIf(){
boolean b = false;
if(b=false){
System.out.println("The value of b is"+b);
}
}
}
Why does this code compile but produces no output?
I thougth it would print "The value of b is false".
Re# 2
public class MySwitch{
public static void main(String argv[]){
MySwitch ms= new MySwitch();
ms.amethod();
}
public void amethod(){
char k=10;
switch(k){
default:
System.out.println("This is the default output");
break;
case 10:
System.out.println("ten");
break;
case 20:
System.out.println("twenty");
break;
}
}
}
Can someone explain the line: char k = 10;
How come it's legal?
Thanks a lot!