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..

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...









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
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
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
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
alter data type
alter data type  alter data type of subName column for subject table to varchar(40
SERIAL data type
SERIAL data type   hello, What is SERIAL data type in MySQL?   hii,ADS_TO_REPLACE_1 SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
PHP Array Type
PHP Array Types: In PHP an array is more than just array, it is an ordered map. A map is a type that we can associate values to keys. We can consider it as an array, list or vector, hash table, etc.  In associative array a key may
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
to save memory in array and default value is 0.0f . double : double data type... 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
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
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 
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
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
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
Get Length of Array
Get Length of Array       Array is defined as data of similar data type. It is defined as data storage method to store information. A array is  considered as a group
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
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
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
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     
Mysql Alter Data Type
Mysql Alter Data Type       Mysql  Alter Date Type is used to modify or change the Column... an example on 'Mysql Alter Date Type'.To understand this example we create a table
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
PHP Integer Data Type
Learn PHP Integer Data type: In PHP integers can be decimal which is a normal... size of the integer data type is platform dependent. Usually the size of integer... be converted to float data type. PHP Integer Data Type Example:ADS_TO_REPLACE_2 <
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
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
Spring Wire Array Type To List Element Example
Spring <list> Configuration Element to wire Array type property The list...: This class contains parts attribute which is of String array type. import... path. Its product bean is used to get property of String array type. import
ModuleNotFoundError: No module named 'data_type_tools'
ModuleNotFoundError: No module named 'data_type_tools'  Hi, My... named 'data_type_tools' How to remove the ModuleNotFoundError: No module named 'data_type_tools' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'algebraic-data-type'
ModuleNotFoundError: No module named 'algebraic-data-type'  Hi, My... named 'algebraic-data-type' How to remove the ModuleNotFoundError: No module named 'algebraic-data-type' error? Thanks   Hi
ModuleNotFoundError: No module named 'data_type_tools'
ModuleNotFoundError: No module named 'data_type_tools'  Hi, My... named 'data_type_tools' How to remove the ModuleNotFoundError: No module named 'data_type_tools' error? Thanks   Hi, In your python
C Array Declaration
. To declare an array in C, you have to specify the name of the data type and the number... an array   data_type [int size] varname;   If the the size is not defined... is the array of integer type. The values inside this array arr or any array can
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
Data Type: String
Data Type: String       This Example shows you how to use string data type in velocity. ... variable. $str: Display string data type variable.  
Data Type: number
Data Type: number       This Example shows you how to use number data type in velocity. Methods used in this example are described below:-  1:- Initialize velocity run
Convert array to Vector
. Actually array is used is used to store similar data types but Vector is used to store object data type and object can be of String or of any class. In the code... Convert array to Vector     
size of all primitive data
size of all primitive data   java program for to find the size of all primitive data types in java
data science for all
data science for all  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: data science for all Try to provide me good examples or tutorials links so that I can learn
data type used to store name.(getting an error)
data type used to store name.(getting an error)    Statement stm=con.createStatement(); String query="select * from employee where ename=\'"+ename+"\'"; ResultSet rs=stm.executeQuery(query
Conversion from string data type into different data types.
Conversion from string data type into different data types.  string str="World id Beutifull"; char chr[20]; char* chrctr ; Qustion is -How to store the 'str' value in 'chr' and 'chrctr'? int abc; sprintf(abc ,"%s",str
Identify Excel's cell data type
Identify Excel's cell data type In this section, you will learn how you can identify cell's data type and handle it appropriately using Apache POI. In Apache POI library, for fetching each type of data, there is separate
Managing Multiple User Input Data in an Array (or ArrayList)
Managing Multiple User Input Data in an Array (or ArrayList)  Hey... record alphabetically (2) If user chooses choice1, the input data is stored in an ARRAY (or ARRAYLIST) until the user chooses to stop inputting data. Kindly

Ads