Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners array accept all data type
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


didar sham
array accept all data type
1 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


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


Advertisement
View Answers

January 22, 2011 at 10:48 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



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
size of all primitive data
size of all primitive data   java program for to find the size of all primitive data types in java
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, SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
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
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
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
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
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
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
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
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
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
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
Mysql Alter Data Type
Mysql Alter Data Type       Mysql  Alter Date Type is used to modify or change the Column... Alter Date Type'.To understand this example we create a table 'userform
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
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 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 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
PHP Integer Data Type
Learn PHP Integer Data type: In PHP integers can be decimal which is a normal... data type is platform dependent. Usually the size of integer is 2 million in 32... type. PHP Integer Data Type Example: <?php $a=12; echo"
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
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: 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
Data Type: String
Data Type: String       This Example shows you how to use string data type in velocity. ...: Display string data type variable.   DataTypeString.java
Advertisements
 

 

 

DMCA.com