is it possible that i could create an array from a class and return the value of that array? and how? how can i access that array

Recommended Answers

All 3 Replies

Yes its possible to create an array in a class and multiple ways to return it depending on what your trying to do, So what are you trying to do?

for example, i am accessing values from a database.. i want to store them in an array.. but my problem is i can't access my array on my jsp page..
it returns null.. my program is quite long so i hope you could help me with a simple program so that i can pattern your program with mine. thanks really..

Here is some simple code that will show you how to access private variables in a class, If this is not what your looking for let me know.

public class myClass{

      private int[]  myArray = new int[10];

     //return value of specified index      

      public int value(int indexNumber)
     {
         return myArray[indexNumber]
     }

     //returns the array to the calling object

     public int[] getArray()
    {
         return myArray;
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.