View Single Post
  #1 (permalink)  
Old 07-18-2007, 06:11 PM
silvia silvia is offline
Member
 
Join Date: Jul 2007
Posts: 35
silvia is on a distinguished road
I have a problem with variable "i"
I have a problem. Why does the program ask me for the variable "i" three times, and how could I fix it?
Sorry for making it so long, but I don't know any other way of illustrating my problem..

Code:
import java.util.*; public class Test { public static void main (String args[]) { Testing1 T; T = new Testing1(); T.Testing1Method(); Testing2 T2; T2 = new Testing2(); T2.Testing2Method(); Testing3 T3; T3 = new Testing3(); T3.Testing3Method(); } }
Code:
//Testing1.java import java.util.*; public class Testing1 { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); public void Testing1Method() { System.out.println("Test1= " + i); Testing2Method(); } public void Testing2Method() { } }
Code:
//Testing2.java public class Testing2 extends Testing1{ public void Testing2Method(){ super.Testing2Method(); System.out.println("Test2 " + i); Testing3Method(); } public void Testing3Method() { } }
Code:
//testing3.java public class Testing3 extends Testing2 { public void Testing3Method() { super.Testing3Method(); System.out.println("Test3 " + i); } }
Thanks
Reply With Quote
Sponsored Links