Alright bro...Now I've understood. Meaning to say there is only one 'main' if involve two classes. Many thanks.
How to select an input from a set of inputs?
Collapse
X
-
Allow me to continue additional Q in this topic..need someone to guide me please.
Firstly, the classes & methods used are still the same - TestDriver.java & MyProgram.java. TestDriver is passing int value 'a' to MyProgram. Because a testing tool that currently I'm using needs TestDriver & MyProgram to have 'main' . How if I set an array of 'int a' stored in a file? Back to my first post - anything to do with serialization?
e.g.
First TestDriver pass int a=1 to MyProgram and do some testing stuff here. Then I need to select an int a (other) from the file (which doing by TestDriver) to run MyProgram...
Code:int[] values = {1, 2, 3, 4}; something(values[1]);
Comment
-
Originally posted by shana07Allow me to continue additional Q in this topic..need someone to guide me please.
Firstly, the classes & methods used are still the same - TestDriver.java & MyProgram.java. TestDriver is passing int value \\\'a\\\' to MyProgram. Because a testing tool that currently I\\\'m using needs TestDriver & MyProgram to have \\\'main\\\' . How if I set an array of \\\'int a\\\' stored in a file? Back to my first post - anything to do with serialization?
e.g.
First TestDriver pass int a=1 to MyProgram and do some testing stuff here. Then I need to select an int a (other) from the file (which doing by TestDriver) to run MyProgram...
Code:int[] values = {1, 2, 3, 4}; something(values[1]);
You can write the array to a file if you want but see if this will not work here.
Code:class A { int[] a = new int[20]; //class A contains an array that is required by class B }
Then
Code:class B { int[] x; B(A a) { //Pass an A to B x = a.a; } something(x[1]);//now use the array from A in B.
Comment
-
I've tried your suggestion as above. got error but let it be first...I'll inform again about it.
I have one Q here, I ran a program with an error:
Code:class Mode has no static field {1
Code:class Program { public static void main(String[] args) { int a = TestDriver.getInt( 0, 4); //FETCHING FROM ONE CLASS if(a<5) { System.out.println("if-1: True"); .......... ......
thank uComment
Comment