Skip to content
Advertisement

Tag: list

Find substring in List and return Index Number

I have an List, with Strings like: Now i would like to get the Index Number for the Substring “One”. How can i get this? I only could make it if i convert it to an Array and then: Isn’t there a way to search for the Substring without converting it to an Array? Answer List already contains indexes

hasPrevious() Method not working

I don’t understand why my hasPrevious iterator is not functioning, it looks like this: I have another function using hasNext() and it works, but this one will not. I am not sure if this method is no longer in existence or not, but when I look into it, Java websites speak of it. I don’t understand why it is not

How to convert list data into json in java

I have a function which is returning Data as List in java class. Now as per my need, I have to convert it into Json Format. Below is my function code snippet: I tried To convert into json by using this code but it is giving type mismatch error as function is of type List… Please help me resolve this.

How to search in a List of Java object

I have a List of object and the list is very big. The object is Now I have to search for a specific value of an object in the list. Say if value3==’three’ I have to return those objects (My search is not always based on value3) The list is What is the efficient way of doing it? Thanks. Answer

Declaring a List field with the final keyword

If I have the following statement within a class where Synapse is an abstract type: Does final allow me to still be able to change the state of the Synapse objects in the List, but prevent me from adding new Synapse objects to the list? If I am wrong, could you please explain what final is doing and when I

3-Dimension List or Map

I need something like a 3-dimension (like a list or a map), which I fill with 2 Strings and an Integer within a loop. But, unfortunately I don’t know which data structure to use and how. Answer Create an object that encapsulates the three together and add them to an array or List: If you want to insert into a

Java : list that contains unique elements in order

Is there a list type in java that stores objects in ascending order and not adds if this object is previously added. I know java maps can do that but I wonder if there is a list type that does what I want. Otherwise I have to override contains, equalsTo and add methods,right? Answer So you need a list containing

Why no tail() or head() method in List to get last or first element?

I recently had a discussion with a collegue why the List interface in Java doesn’t have a head() and tail() method. In order to implement such a functionality would have to write a wrapper that looked something like this: I’m not aware of all List implementations but I assume that at least in LinkedList and ArrayList it should be pretty

Advertisement