Results 1 to 4 of 4
Thread: Generic array
- 12-21-2007, 09:19 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 49
- Rep Power
- 0
- 12-21-2007, 12:19 PM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 697
- Rep Power
- 6
You can create an object array. If you use the auto boxing feature you can just put any object in the array.
Is this help you?Java Code:Object[] data = new Object[2]; data[0] = 10; data[1] = "hello";
Website: Learn Java by Examples
- 12-22-2007, 12:40 PM #3
or u can use the arraylist man..then u can put any type of variable or any type of object into that oone thats useful 2 u i think..
public class Testing
{
public static void main(String args[])
{
Integer i1=new Integer(45);//Integer object
Double d1=new Double(45.567);//double object
String s1=new String("agsd");//string object
Calc c1=new Calc();//object of the class
ArrayList a1= new ArrayList();
a1.add("45");// u can insert direct values also like this
a1.add("a");
a1.add("4de5");
a1.add(45);
a1.add(45.56);
a1.add('a');
a1.add('4');
a1.add("45.79");
a1.add(i1);a1.add(d1);a1.add(s1);
a1.add(c1);
System.out.println(""+a1);
}
}
- 12-23-2007, 12:12 AM #4
Member
- Join Date
- Dec 2007
- Posts
- 49
- Rep Power
- 0
Similar Threads
-
A generic framework for a flexible, multi-threaded server
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:14 PM -
can anyone help... 2d Array
By Mark1989 in forum New To JavaReplies: 2Last Post: 03-12-2008, 08:59 PM -
Writing generic methods
By eva in forum New To JavaReplies: 2Last Post: 12-31-2007, 03:28 AM -
Generic Hashtables
By ShoeNinja in forum New To JavaReplies: 0Last Post: 12-04-2007, 10:43 PM -
Generic Eclipse Modeling System 3.0 RC1
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-25-2007, 04:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks