java - need help accessing information in embedded classes -


long story short, want method return 2 items. think learned best way embedded class. i'm having difficulty structure , syntax though, how access info.

really want have method return array string[] , string. if can think of easier way i'd interested in hearing it.

thank help

thanks

import java.util.*;  public class test {  public test() { }  public class sqlarguments //embedded class {     string[] columns;     string table;      public  sqlarguments(string table, string... columns)      {         this.table = table;         this.columns = columns;     } }  public sqlarguments arguments(string table, string... columns) {     sqlarguments testargs = new sqlarguments(table,columns);             return testargs; }  public static void main(string[] args)   {     test t1 = new test();     t1.arguments("table","col 1","col 2", "col 3");     system.out.println(.arguments[0]);     system.out.println("test"); }//end main  }//end class 

i reorganized code put test methods , sqlarguments methods together. changed name of main class test, because class names in java start capital letter.

i added 2 getter methods sqlarguments class, can retrieve values set in constructor. used 1 of getter methods in test main method.

here's code:

public class test {      public test() {      }      public sqlarguments arguments(string table, string... columns) {         sqlarguments testargs = new sqlarguments(table, columns);         return testargs;     }      public static void main(string[] args) {         test t1 = new test();         sqlarguments arguments =                  t1.arguments("table","col 1","col 2", "col 3");         system.out.println(arguments.getcolumns()[0]);         system.out.println("test");     }   //end main      public class sqlarguments {     // embedded class         string[]    columns;         string      table;          public sqlarguments(string table, string... columns) {             this.table = table;             this.columns = columns;         }          public string[] getcolumns() {             return columns;         }          public string gettable() {             return table;         }      }  } 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -