Results 1 to 6 of 6

Thread: Retrieve multiple values from java class

  1. #1
    Join Date
    Dec 2009
    Posts
    204

    Retrieve multiple values from java class

    Hello,
    I have a concern I must retrieve multiple values from a java class declare "enum"
    Code:
    so here the vals recovered:
    test.setInfo(TableCalcul ..val1);
    test.setInfo(TableCalcul ..val2);
    test.setInfo(TableCalcul.val3);
    The problem is that TableCalcul is declared with enum and I must retrieve the list of values. Should I have a For loop somewhere? Do you have any idea about it.

  2. #2
    Join Date
    Dec 2009
    Posts
    178

    Re: Retrieve multiple values from java class

    Hello,
    I am new to java and have don some programs, I think you should use the if conditional statement here. Here it is how you can use
    Code:
    / / General Info 
    		if (test.getInfo() != null ) {
    		TableCalcul info = foo.getInfo();
    		}
    And getInfo method will return a value but not all values cassettes. I have not tried this but I think you can do this.

  3. #3
    Join Date
    Nov 2009
    Posts
    359

    Re: Retrieve multiple values from java class

    Hello,
    I think with your class. If your method setInfo () be content with a simple assignment is normal that you only have one item at a time. If you want to have more you must maintain a list in your class. In passing the name of the method should rather be addInfo () that setInfo ().

  4. #4
    Join Date
    Dec 2009
    Posts
    204

    Re: Retrieve multiple values from java class

    Hello,
    I have even tried the following code but it does not work for me. Here is the code
    Code:
    Public void addInfos(Class Info) {
    		
                  List result = <String> new ArrayList <String>();
    result.add(Info);
     
    }
    I am a beginner in java and I would love some help for you guys.

  5. #5
    Join Date
    Nov 2009
    Posts
    446

    Re: Retrieve multiple values from java class

    Hello,
    Have a look at the following code, I think this may help you.
    Code:
    import java.util.ArrayList;
    import java.util.Iterator;
     
    Public class Test {
        
        ArrayList res = <String> new ArrayList <String>();
        
        Public void AddInfo(String info) {
            res.add(Info);
        }
        
        Public void printContent() {
            for (Iterator it = res.iterator(); It.hasNext(); ) {
                System.out.System.out.println(it.next());
            }    
        }
        
        Public static void hand(String[] args) { 
            Test t = new Test();
            t.AddInfo("tst");
            t.AddInfo("tst1");
            System.out.System.out.println("What is res?");
            t.printContent();
        }
    }

  6. #6
    Join Date
    Nov 2009
    Posts
    518

    Re: Retrieve multiple values from java class

    Hello,
    For the following statement in you code, watch below
    Code:
    for (Iterator it = result.iterator(); It.hasNext(); )
    Rather it is more attractive, just use this in your code you will feel more comfertable with your code
    Code:
    for(String s: result)
    If you have any more queries regarding this then you can post back. Hope you will solve your query.

Similar Threads

  1. Replies: 4
    Last Post: 20-01-2012, 11:56 AM
  2. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  3. Comparison two Class values in java
    By ISAIAH in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 05:37 AM
  4. php return multiple values
    By Aston5 in forum Software Development
    Replies: 2
    Last Post: 29-06-2009, 10:14 PM
  5. Use DDE to retrieve values
    By machok in forum Software Development
    Replies: 3
    Last Post: 06-04-2009, 03:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,930,598.34007 seconds with 16 queries