Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to store and retrive a set of values without using an
array

Answers were Sorted based on User's Feedback



how to store and retrive a set of values without using an array..

Answer / shiva

I think U need this .......

/*****************************************************/
import java.util.*;

class TreeSetDemo {
public static void main(String args[]) {
// Create a tree set.
TreeSet<String> ts = new TreeSet<String>();

// Add elements to the tree set.
ts.add("C");
ts.add("A");
ts.add("B");
ts.add("E");
ts.add("F");
ts.add("D");

System.out.println(ts);
}
}

/******************************************************/
The output from this program is shown here:
[A, B, C, D, E, F]
/*******************************************************/

/********************************
************ AND ************
**********************************/



import java.util.*;

class HashSetDemo {
public static void main(String args[]) {
// Create a hash set.
HashSet<String> hs = new HashSet<String>();

// Add elements to the hash set.
hs.add("B");
hs.add("A");
hs.add("D");
hs.add("E");
hs.add("C");
hs.add("F");

System.out.println(hs);
}
}

/**************************************/
The following is the output from this program:
[D, A, F, C, B, E]
/****************************************/

Is This Answer Correct ?    12 Yes 6 No

how to store and retrive a set of values without using an array..

Answer / r.jude silvester

You can use any of Collections like Vector,ArrayList or HashSet etc.

Is This Answer Correct ?    5 Yes 2 No

how to store and retrive a set of values without using an array..

Answer / madhura

impotr java.util.*;
class store
{
public static void main(String args[])
{
Vector v=new Vector();
for(int i=0;i<10;i++)
{
v.addElement(i);
}
System.out.println("the elements in vector are"+v);
}}

Is This Answer Correct ?    3 Yes 2 No

how to store and retrive a set of values without using an array..

Answer / r.jude silvester

You can use any of the Collections for eg.ArrayList

Is This Answer Correct ?    0 Yes 1 No

how to store and retrive a set of values without using an array..

Answer / shanu zabeen

import java.util.*;
import java.io.*;
public class Store
{
public static void main(String args[])
{
System.out.println
("enter number of elements to be stored");
Scanner cin=new Scanner(System.in);
int n=cin.nextInt();
Vector v=new Vector();
for(int i=0;i<n;i++)
{
v.addElement(i);
}
System.out.println("the elements in vector are"+v);
}}

Is This Answer Correct ?    0 Yes 1 No

how to store and retrive a set of values without using an array..

Answer / karthik

link list i think..

Is This Answer Correct ?    3 Yes 6 No

how to store and retrive a set of values without using an array..

Answer / kiran

please post the answer...



thanks and regards
kiran.y

Is This Answer Correct ?    3 Yes 7 No

how to store and retrive a set of values without using an array..

Answer / ashok kumar

using
BufferedReadered br=new BufferedReader(new InputStreamReader
(System.in));
while (br.readline)
System.out.println(br);



















B

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More J2SE Code Interview Questions

write a program in java to solve a system of n-variabled simultaneous equations using the guassian elimination method. let the maximum possible value of n be 100. run the program using hypothetical values for a set of 10- variables simultaneous equations. print out the program, the input equation and the results generated by the program.

0 Answers   TCS,


how to print a message to console without using main() function?(do not use even static blocks also.)

14 Answers   Google, Zoho,


I am trying to pass the string firstName from a Servlet called SampleServet. I am running this on eclipse and it tells me that "the value for annotation attribute must be a constant expression. I don't understand why it is giving me this error. @PersonAnnotation(name = SampleServlet.firstName) public class AnnotationClass{

0 Answers  


how to store and retrive a set of values without using an array

8 Answers   FCS, HCL, Maximus,


Program to print map of India in java.

2 Answers  


In java, why do we set thread priority, when we know that there is no guarantee by which a thread should be execute?

0 Answers   Google, Microsoft,


inner join,outerjoin,trigger,stored procedure explain with code snippets?

1 Answers   IBM,


Why the program getting error if we don't use String args[] in main(), even in the case of not getting any arguments from command line?

1 Answers  


How can we get the details for printing the employee details at run time using JDBC connectivity? can u provide the coding for that? Its urgent?

2 Answers  


Is there any static classes are in java give some examples

0 Answers  


For printing a message we use System.out.println in normal programs. We use String msg="text....."; Can't we use String msg=" " in normal programs and System.out.println("........") in applets. Please answer this question?

0 Answers  


Design a program using one-dimensional array that determines the highest value among the eight input values from a user. Display the difference of each value from the highest to the lowest.

1 Answers   RoboSoft,


Categories