Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need help with foreach method to LinkedList in Java 8.
I need to start from second element. I don't know how to do this.
You can skip the first element: list.stream().skip(1).forEach(...). Note that the skipped elements will still be traversed by the stream, so for a random access list such as ArrayList it is much more efficient to use a loop starting from the relevant index if this index is very large. In your case it doesn't matter because your starting index is small and your list doesn't support random access.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 days ago.
Improve this question
while writing a code of bfs for graph we are using for each loop for extracting values from adjacency list, wanted to know how this int it is getting all the values of each and every element of 2d list?
this is code for bfs traversal of graph
I have tried to extract every element of adjacency list ans marking it as true if it is false in arr.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to check if a List of characters like {a,a,d,e} is contained in a list like {a,d,e} in java. I want the answer to be false but I have no idea how to go about doing this. All help would be appreciated :)
Try using the retainAll() method and check for the result. col1.retainAll(col2) leaves all elements in col1 that are also in col2. If the size of col1 is the same before and after the call, the whole col2 is contained.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a different way of permuting a list like [apple, banana, orange] without using for loops recursively that will work for any size list and input etc. I already created one with using for loops, but I can't figure out myself without using for loops to solve the problem as this second part of solving a permutation without a for loops recursively is also going to be a question on our next exam (study guide I am reading) any idea how I would tackle this so I can see and understand how it works for the next exam question?
You can emulate a loop by the following recursion:
do nothing for the empty list
otherwise
work on the first element
recurse, using the sublist that starts with the second element
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i want to do inorder traversal not using recursive and to put the nodes in an array given the size of the BSTmap, it is easy to use recursive put i need to put the nodes in an array !!
Does it have to be an array? If not, you could use a linked list to add and remove the nodes without needing to know the size of the BSTmap.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have an array of strings but the values in array is changing continuously changing.
Is there any other way of managing the array except removing items and changing index locations?
public int[] deviceId=null;
deviceId=new String[deviceCount];
in my case deviceCount is changing as new device comes. so i continuously need to change array size and add or remove items
Java offers a really handy mechanism known as the ArrayList. It's a dynamic array that you can use to do what you're describing.
http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html