array accept all data type

Ads
 

array accept all data type

how can create array that accept all data type??? if we can solution it? how..

View Answers

January 22, 2011 at 10:49 AM

Hi Friend,

Try the following code:

import java.lang.reflect.*;
class  CreateArrayOfAllTypes{
    public static void main(String[] args) 
    {
        Object[] arr = (Object[]) Array.newInstance(Object.class, 4);

        Array.set(arr, 0, 1);
        Array.set(arr,1,"A");
        Array.set(arr,2,'B');
        Array.set(arr,3,5.5);

         for (int i = 0; i <arr.length; i++) {
         System.out.println(Array.get(arr, i));
    }
    }
}

Thanks


January 23, 2011 at 12:25 AM

thank u ...so much my friend...thinks thinks thinks thinks.. but if you can using this array in queue how ?? and output like this:(by using switch case) ask user : 1-create array//accept all data type 2-enQueue 3-dQueue 4-search 5-To Exit...

Ads









Related Tutorials/Questions & Answers:
array accept all data type
array accept all data type  how can create array that accept all data type??? if we can solution it? how..   Hi Friend, Try the following code: import java.lang.reflect.*; class CreateArrayOfAllTypes{ public
array accept all data type
array accept all data type  how can create array that accept all data type??? if we can solution it? how..   Hi Friend, Try the following code: import java.lang.reflect.*; class CreateArrayOfAllTypes{ public
Advertisements
bitwise operators accept type char as operands
bitwise operators accept type char as operands   Why bitwise operators accept type char as operands
data type
data type  which data type is used to store video file in mysql databse
JSP Array
JSP Array          Array is defined as the set of similar type of data in series. The Array can be String, int or character kind of datatypes
data type
data type  what are the date types in the java and vb.net? what is the difference between java and vb.net?   Hi Friend, java data types... vb.net data types are: Byte SByte Short UShort Integer UInteger Long ULong
the array list contains similar type of elements or disimilar type of elements
the array list contains similar type of elements or disimilar type of elements  the array list contains similar type of elements or disimilar type of elements
Array list in Java - arraylist type error
Array list in Java - arraylist type error  I am using Array list in Java but when i compile i get array list type error. Can anyone please explain what is array list type error and why it occurs
Array example
Array example       Array is an object that hold the data of similar type. The length of an array is decided when an array is created. Length in array cannot
Data type in java
in large array. Default value is 0. int : int data type is 32-bit signed two's.... Class, array and interfaces are reference data type. Default value of any...Data type in java In this section we will tell you about data type in java
int Array
;    Array is a collection of same data type. Suppose if we have declared an array of type int then the array will take only the int values and not any other data types. We can find find out the length of 
Enum data type
Enum data type  How can we use enum data type in java program?  ... data type. Here we have defined Fruits as enum type by using the enum keyword. Now... data type. Here we have defined Fruits as enum type by using the enum keyword. Now
grouping similar data of array
grouping similar data of array   I have sorted array of integer . how can I define new arrays with similar data . indeed I want to grouping similar data of array . example: input : int num[] = {20,21,21,24,26,26,26,30}; output
Multidimensional Array Java
Multidimensional Array Java          Array is a collection of a same data type. When we have the data of the same type and same scope then its better
array find all possible dimension
array find all possible dimension  Given array: int[] dimension = { 1, 2, 3 }; That produces the output: 1 2 3 12 13 23 123 I'm new to array...i can't figure out the way on even how to start... any idea?...really appreaciate
Java Array Length
Java Array Length In this section you will find a program to find the length of array in java. An array is collection of similar data type. To find the length of array is a simple program in java. Using length function you can find
Two dimensional array in java
of similar data type or it can hold fixed number of value of same type. Two... of array can be of any type object. When we create array then length will be established, it is fixed when created.In two dimension array data
Data Conversion from int to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from int primitive type to another data type like String, boolean and char etc
Data Conversion from String to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from String primitive type to another data type like int, boolean and char etc
Data Conversion from short to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from short primitive type to another data type like String, boolean and char etc
Data Conversion from byte to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from byte primitive type to another data type like String, boolean and char etc
Data Conversion from float to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from float primitive type to another data type like String, boolean and char etc
Data Conversion from double to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from double primitive type to another data type like String, boolean and char etc
Data Conversion from long to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from long primitive type to another data type like String, boolean and char etc
MySQL Boolean Data Type
MySQL Boolean Data Type This example illustrates how create a boolean data type. In this example we create a table 't' where define four field that is 'a' which is BOOL type, 'b' which is FLOAT type, 'c' which is LONG VARCHAR type
how insert data from databse in array and compare new data to already stored value in array
how insert data from databse in array and compare new data to already stored value in array   hello all i tried to fetch data from databse and try to stored it in an array and i want to compare new value that come from database
C Array length example
of an array in C. An array is a contiguous group of data items with the same name and data type. In order to get the length of an array, we have used the sizeof operator... C Array length example     
Modify Data Type with ALTER Command
Modify Data Type with ALTER Command  Is it possible to modify the Data type of a column which has at least one data in it?If it is possible,then what will happen to the data in the column? Example. Table Name: Emp EmpName
Spring Wire Array Type To List Element Example
Spring <list> Configuration Element to wire Array type property The list... is of String array type. import java.util.*; public class Product { private String... is used to get property of String array type. import
accept sentence from user and print all word starts with vowel and end with consonent
accept sentence from user and print all word starts with vowel and end with consonent  Write a program to accept a sentence. Print all the words that starts with vowel and end with a consonant. e.g. input by user "the purpose
Declaring string array
of same data type. Suppose if we have a declare an array of type String, then it will store only the String value not any other data type. When we have a closely related data of the same type and scope, it is better to declare it in an array

Ads