Skip to main content

All Questions

Tagged with
0 votes
2 answers
110 views

Won't return object

private ArrayList players = new ArrayList<Player>(); public Player getPlayerByName(String theName){ for(int i = 0; i < players.size(); i++){ String pName = (String) players....
daydreamingds93's user avatar
1 vote
0 answers
119 views

After reading list containing objects using ObjectInputStream how to iterate through the list?

I have a binary file having some list where each list has group of similar objects I am using ObjectInputStream to read the list series one by one Now, instead of directly printing the list I want to ...
Payel Senapati's user avatar
1 vote
1 answer
72 views

Iterating through a list which is an object of a table

public List<AnswerValues> getAllAnswers(Forms fm){ Session sess = getSession(); Criteria crit = sess.createCriteria(FormQuestions.class); crit.add(Restrictions.eq("fkformId",fm)); ...
bahdotsh's user avatar
  • 467
-2 votes
2 answers
130 views

How to obtain data and iterate over arraylist returned as an object?

In my app I created an ArrayList in some servlet which was assigned using request.setAttribute() as 'testList'. Then request was forwarded to jsp page. Inside jsp page I want to retrieve whole ...
artisticImpresion's user avatar
0 votes
1 answer
810 views

Is there a way to iterate through a two dimensional ArrayList and also invoke the class methods of the objects?

So I am attempting to iterate through a two dimensional ArrayList in Java. Now I have gotten the iteration portion down, however, I can't seem to invoke methods from the object class. I have checked ...
Gh0stwarr10r's user avatar
0 votes
3 answers
65 views

How to determine an objects type without iterating through all possible types?

I have a large collection of classes. These classes have similar properity names but with different values. For example, I have Spearmen, and Swordsman. These two classes have the same properity names ...
Colourfit's user avatar
  • 367
-1 votes
5 answers
4k views

iterate through the objects of a class

I have created this class. public class UserData { private int user_Id; private List<String> disease_List=new LinkedList<String>(); /*Constructor*/ public UserData(int ...
sheldon cooper's user avatar
0 votes
1 answer
3k views

Dynamically create new objects in java [duplicate]

I want to dynamically create objects of a class using an array. This is what i have so far: int[] n = new int[10]; for (int i = 1; i < 5; i++) { MyClass n[i] = new MyClass(); n[i].setNumber(...
Jack Pettersson's user avatar
2 votes
4 answers
275 views

Can't reach fields from super class with object

I'm trying to figure out a nice way to iterate and print out the objects inside my ArrayList. Problem is that i can't seem to reach the fields in which the user is typing the info of the objects (...
Johan Rovala's user avatar
0 votes
2 answers
205 views

Replacing ArrayLists with HashMaps

I am currently working on a project where I am replacing the ArrayLists in my code with HashMaps and I've run into a problem. In this section of my code I am creating a new "Book" from my book class ...
LockSkywalker's user avatar
47 votes
6 answers
272k views

How to iterate through an ArrayList of Objects of ArrayList of Objects?

Using an example: Let say I have a class call Gun. I have another class call Bullet. Class Gun has an ArrayList of Bullet. To iterate through the Arraylist of Gun ..instead of doing this: ...
user3437460's user avatar
  • 17.5k
2 votes
1 answer
79 views

Find and delete specific objects from a Set with minimal iteration using Java

I have a set of objects and each object has its own id... I also have a list of ids, each denoting the id of an object to be removed from the set.. Unfortunately I need the most efficient approach ...
matt's user avatar
  • 83
0 votes
1 answer
277 views

Iterate over HashMap and get "Lowest" Integer of the value in the Object

for (Entry<String, Data> entry : list.entrySet()) { if(entry.getValue().getRoom() == 1){ if(entry.getValue().getName().equalsIgnoreCase("RED")){ entry....
user1621988's user avatar
  • 4,355
0 votes
3 answers
779 views

When creating objects through iteration, how do I get a specfic object?

I got an instance variable of type GRect private GRect brick; that I create several of, through iteration private void makeBrickLineX(int x, int y, Color color) { for (int i = 0; i < ...
Tom Lilletveit's user avatar
0 votes
3 answers
19k views

Iterate through list of objects & methods using for loop

The entirety of the code can be found at the bottom of this post, but the only part that really concerns me is, for(zed = 0; zed<photoes.size(); zed++) { totesPrice += photoes<zed>.getCost();...
user1251814's user avatar