i have following two doubts from K & B book: 1. final int a = 1; final int b; b = 2; int x = 0; switch (x) { case a: // ok case b: // why this is compiler error
2. byte g = 2; switch(g) { case 23: case 128: } in the preceding code byte is cast to an int then why 128 is large as case constant?
manny singh
Greenhorn
Joined: Jan 18, 2008
Posts: 28
posted
0
1) final int b=2; (must be initialized as declared else only allowed in construtors)
2) 128 = -1 ?
Right or not?
Sandeep Bhandari
Ranch Hand
Joined: Apr 16, 2004
Posts: 201
posted
0
Originally posted by Abhishek Mantri: i have following two doubts from K & B book: case 128: in the preceding code byte is cast to an int then why 128 is large as case constant?