Variable Scope Brackets brackets brackets Variable Scope Hello
Variable Scope Brackets, brackets…. brackets
Variable Scope /** * Hello. World --- program that prints something to the screen. * @author Blanca Polo */ public class Hello. World{ public static void main (String arg[ ]){ String s = “Hello World!!!”; System. out. println( s ); } }
Variable Scope public class Parse. I{ public static void main (String arg[ ])throws Exception{ Input. Stream. Reader isr = new Input. Stream. Reader(System. in); Buffered. Reader br = new Buffered. Reader(isr); int i. Num = 0; String s. User. Input = ""; System. out. println("Enter a number please "); s. User. Input = br. read. Line( ); System. out. println("You typed " + s. User. Input); //risky code try{ i. Num = Integer. parse. Int(s. User. Input); System. out. println("Thanks for the number!!! "); } catch(Number. Format. Exception nfe){ System. out. println("I asked for a number, dummy!!"); } System. out. println("- - the end - - "); } //main } // class
Variable Scope public class Parse. I{ public static void main (String arg[ ])throws Exception{ Input. Stream. Reader isr = new Input. Stream. Reader(System. in); Buffered. Reader br = new Buffered. Reader(isr) //risky code try{ String s. User. Input = ""; System. out. println("Enter a number please "); s. User. Input = br. read. Line( ); System. out. println("You typed " + s. User. Input); int i. Num = 0; i. Num = Integer. parse. Int(s. User. Input); System. out. println("Thanks for the number!!! "); } Var. Scope. java: 22: cannot find symbol : variable s. User. Input location: class Var. Scope System. out. println("and you typed "+ s. User. Input); ^ catch(Number. Format. Exception nfe){ 1 error System. out. println("I asked for a number, dummy!!"); System. out. println(”and you typed “+ s. User. Input); } System. out. println("- - - } //main } // class the end - - ");
- Slides: 4