Solved

Passing hardcode data to method

Posted on 2013-06-19
2
375 Views
Last Modified: 2013-06-24
Please excuse my ignorance, as I've indicated, I am a beginner.

I've created a java class, DataIn to contain harcoded data.

I need to pass the list of data to the methods listed below.
class DataIn{
    private int DataInId;
    private int snpID;
    private int indID;
    private String inCode;
    private int total;
    private int count;
    private String inText;
    private String inLabel;
    private String ind_name

    private DataIn(int DataInId, int snpID, int indID. String inCode,
                       int total, int count, String inText, String inLabel)
   {
        this.DataInId  = DataInId, ;
        this.snpID,  = snpID,
        this.indID; = indID;
        this.inCode = inCode;;
        this.total = total;
        this.count = count;
        this.inText = inText;
        this.inLabel = inLabel;
        this.ind_name = ind_name;
    }


    DataIn[] dataItems =
   {
 
    new (13071, 1, 45, "9100", 4,  5,  "",    "OFFSITE", "TC"),
    new (13070, 1, 5,  "9100", 15, 5,  "-10", "COMMUTE", "INDEX"
    new (13068, 1, 31, "9100", 1,  2,  "",    "OFFSITE", "BOOKS"),
    new (13080, 1, 31, "8370", 1,  1,  "",    "OFFSITE", "BOOKS"),
    new (13086, 1, 31, "8999", 0,  0,  "",    "OFFSITE", "BOOKS"),
    new (13089, 1, 31, "6048", 3,  6,  "",    "OFFSITE", "BOOKS"),
    new (13091, 1, 22, "6048", 5,  2,  "-3",  "COMMUTE", "AUTHORS"),
    new (13069, 1, 22, "9100", 6,  3,  "-3", "LOCAL",   "AUTHORS"),
    new (13081, 1, 22, "8370", 8,  6,  "-2",  "LOCAL",   "AUTHORS")
   
 
   
   };


HOW DO I PASS THE DATA IN THE DATAIN CLASS CREATED ABOVE INTO THIS METHOD????

 public void getDataIn( pass the array  DataIn into this method)
    {
       

        // Get a list of all the books
          List<DataIn> dList   = getBooks(arrayitems, "BOOKS"),

               

    }
   
 HOW DO I ACCESS THE ITEMS PASSED TO THIS METHOD?????

    public List<DataIn> getBooks(List<DataIn> DataItems,String indrName)
      {
            List<(List<DataIn> > resultList = new ArrayList<(List<DataIn> >();
            
            for DataIn vo : DataItems, String
            {
                                    
              //IF indrName in the List = "BOOKS" ADD TO LIST                               
                        
             if (indrName = DATAIN LIST

                                    {                        
              resultList.add(vo);
             }
 
                    }
            
            return resultList;
      }
0
Comment
Question by:cookiejar
2 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39261010
You wouldn't normally have an array of type X defined in type X, so you need to look at that. Also, make sure all your variable names begin lower case
0
 
LVL 7

Accepted Solution

by:
gudii9 earned 500 total points
ID: 39261028
Here is good example


class Account{
  int a;
  int b;
 public void setData(int c,int d){
   a=c;
   b=d;
 }
 public void showData(){
   System.out.println("Value of a ="+a);
   System.out.println("Value of b ="+b);
 }
}
 
class ObjectArray{
   public static void main(String args[]){
     Account obj[] = new Account[2] ;
     //obj[0] = new Account();
     //obj[1] = new Account();
    obj[0].setData(1,2);
    obj[1].setData(3,4);
    System.out.println("For Array Element 0");
    obj[0].showData();
    System.out.println("For Array Element 1");
     obj[1].showData();
  }
}




http://www.javatutorialhub.com/java-arrays.html


Hope this helps solving your issue
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse argument 14 61
Java Loop 6 62
use lov values 2 50
by zero exception 10 41
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question