How to select an input from a set of inputs?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shana07
    Contributor
    • Jan 2007
    • 280

    #16
    Alright bro...Now I've understood. Meaning to say there is only one 'main' if involve two classes. Many thanks.

    Comment

    • shana07
      Contributor
      • Jan 2007
      • 280

      #17
      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

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #18
        Originally posted by shana07
        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]);






        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

        • shana07
          Contributor
          • Jan 2007
          • 280

          #19
          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
          my code is:
          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");
                 ..........
           ......
          What's that mean....
          thank u

          Comment

          Working...