I have some classes and I'm trying to fill the objects of this class. Here is what i've tried. (Question is at the below)
public class Team
{
private String ...
|
My problem is i have a class and in it there is a list of elements of another class.
public class Branch
{
private ArrayList<Player> players = new ArrayList<Player>();
...
|
List<String> listA = new ArrayList<String>();
listA.add("a");
listA.add("b");
listA.add("c");
listA.add("d");
List<String> listB = new ArrayList<String>();
listB.add("c");
listB.add("d");
listB.add("e");
listB.add("f");
ListB contains two elements that are also present in ListA ( "c" and "d").
Is there a clean way to make sure that listB does ... |
how can you edit the contents of an array list using a value generated by the user using the scanner class.
many thanks
|
Just a quick question about the above subject. Basically, I'm writing a piece of software which captures data from the network and writes it to an external file for further processing.
What ... |
Hey there. I have a problem on a program I'm making that I honestly can'd find a solution for. It seems the objects contained on a Java ArrayList collection are being ... |
My code runs an algorithm on an array, and stores the results in an ArrayList. The problem is that I am not able to access the contents of the ArrayList ... |
|
I have many Arraylists having String objects , and I have a requirement to concatenate there values.
Eg:
ArrayList finalList = new ArrayList();
ArrayList catMe = new ArrayList();
ArrayList x = new ArrayList();
x.add("Green");
x.add("Red");
ArrayList y = ...
|
I have a arraylist(eg.CustInfo) which contains a collection of objects(Cust_details,Cust_Auth) for java classes, which in turn has collection of values for the variables(eg.Cust_name,Cust_addr) defined.
Now my problem is that I have a ... |
Hi All, While taking one of the parctice test I stuck in the following code. Can anybody help me to figure the correct amswer: FileOutputStream f=new FileOutputStream("TestSerial"); List alist=new ArrayList(); /* .. ....... */ // Serialize list 'alist' and all its contents to stream f. // Blank Which one of the following lines of code will serialize list 'alist' and all ... |
i have just learned how to print a text ( not a text file ) in Java, and i also have just learned how to make a program with GUI using AWT and SWING ( i understand only a little bit of those two techniques, just adequate for me to make my program works ). now what i'm trying to do ... |
Is it possible to dynamically determine the contents of an arraylist in java 5 using reflection. Since in Java 5, we declare an arraylist as ArrayList, i am expecting some way to determine the type of E. Its possible to dynamically determine the type of the contents of an arrays like this: Class arrayComponentType = expected_Param.getComponentType(); Thanks, Sandeep. |
|
Thanks for the code snippet, I have tried it and it worked. However, when I debugged the program, I only get one character at a time I want to store this characters in an Array then convert it to a string. And when I added this: result = writer.toString(); [B]System.out.println("Result: " + result);[/B] so that I can see its contents, the ... |
|
Avoid using "\n" to write new lines in a file as this won't work for all OS's. Regardless, you may be having problems from not flushing or closing the FileWriter, but with the small bit of code posted, I don't know for sure. Myself, I'd wrap that FileWriter in a PrintWriter object, one that I've turned auto-line flushing on (check out ... |
First of all, let me say yes this is for a class at school. Sorry if that is an issue for you, I am only trying to learn what I have done wrong. I do not expect you to do any work for me, and really appreciate any time you can give. This is the first time I have used an ... |
|
Okay, that will be a little extra work, but it won't be too hard. Read what you can here about BufferedReader. That little line of code near the top shows you how to declare it and set the file name. http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html Then you can call readLine() on the BufferedReader object to read a line of the file. You could do this ... |
|
In my web application, I have been asked to retrieve data from the database in the JSP page. The data are stored in the ArrayList. I have a query screen where I select begin year, end year, and quarter. Each year has 4 quarters. I am able to retrieve data for 1 year, but I am not able to retrieve data ... |
|
|
Yes, you can't modify a List directly while iterating through it. It would confuse the iterator. If you are going to delete entries in passing, use an Iterator explicitly and call the remove method of the Iterator, instead of that of the list. Too late! Work interrupts again. Edited by: malcolmmc on May 6, 2009 4:51 PM |
|
|
can anyopne help me on this..ppl like cotton.m who cant help or unable to answer to queries can mind their own job than commenting..... Could I just point something out here. You are mad at me (and started this thread) because I pointed out in your last thread that your situation seemed hopeless since you were talking only in buzzwords demonstrating ... |