I have an ArrayList of Nodes. One of the fields of Node class is level. I would like to find the level of the node that has the maximum level in the list. This code gives me an NullPointerException... private int findMaxLevel(ArrayList<Node> nodes)
I'm working on cart functionality in one of my projects. We are using Laravel 5.3 and cart item is stored in Laravel session as an array. So if I have 3 items in my cart (add_to_cart Laravel session) it looks like this: array:3 [▼ 0 => array:6 [▼ "
I'm using Netbeans/GUI to make a fantasy basketball game program. I'm trying to create methods that create arraylists, that way I can call the method for the array every time I need it for one of my button events, rather than recode the array under e
I have a static array list in class called cart, is there a way to implement event listener to be used by other classes? I am new to c# tried to understand PropertyChangedEventHandler with no success. The arraylist and property are initialized as bel
I have an ArrayList that stores notes (strings) in the form of "do the dishes". I have a notes class with a method that is supposed to go through all the notes in the ArrayList and count the number of times a certain letter appears. This is the
I'm fairly new to Java so don't attack me lol but I've created two classes and an ArrayList in one of them. I can't compile and get this error: "incompatible types: java.lang.String cannot be converted to int" but nothing is being converted here
My program is supposed to take words and definitions from the user and display them like flash cards. I've got all the words sorted out into classes and such and now all I need to do is make it so that when a button is pressed by my application, the
For an assignment, I have an ArrayList of type "Reference". Reference is a parent class to the "Book" class and "Journal" class. If I am allowed to add objects of type "Book" and "Journal" to the Arraylist
So my code is supposed to return the amount of words (words being lengths of letters) and it works except for when i enter anything 0 or less can some pplease help spot the error?? Edited Code: public class WordCount { public static int countWords(St
Assuming I had a class Groceries(name,quantity) and the class is used for an array list called shoppingList. ArrayList<Groceries> shoppingList = new ArrayList<>(); The names and quantities of items would be stored in this array list. An item t
How would I go about only inserting an item if the item does not have the same name as the other items in the arraylist within my insertUniqueItem() method? public void insertUniqueItem() { } public static void main(String[] args) { ShoppingCart sc =
I am writing a program that creates a game board, and uses a superclass and subclasses to generate the board. Essentially, I want to use an arrayList that stores the values returned back from the methods of the subclasses of Cell. But I cannot figure
This code is from the famous Java SCJP6 book. I can't understand the difference between title and d.getTitle() in the compareTo method. How are both title and d.getTitle() getting and comparing values? class DVDInfo implements Comparable<DVDInfo> {
I am using the arrayList.remove(index) function. I want to remove 40320 elements from array and it will be done 9 times in my program execution . It's taking so much time. This causes my program execution to be slow. Is there any efficient method to
Hello i am trying to build a listview and populate it from values in Mysql database. The list with SimpleAdapter works but i decided to change the listview and use my own adapter that extends ArrayAdapter and create my own listItem and not the HashMa
I'm creating two ArrayLists from pre-defined arrays. I need to take each element of the two ArrayLists and multiple the values, with the answers being stored in a third ArrayList. For example: ListA[0] * ListB[0] = ListC[0] I need to output all three
I want to match an exact string in an ArrayList<String>. Currently this code will execute if myArrayList.contains(wordImLookingFor). if (myArrayList.contains(exactWordImLookingFor)) { Toast.makeText(getApplicationContext(), "Match", Toast.
I am building an android app and I am having trouble with an ArrayList. I am using it to store strings and then putting those strings into a list. I can add new items to the ArrayList no bother but if I go to a new activity and go back to this list t
I have a ArrayList<MyDataType> pList; where MyDataType is a simple class like below: class MyDataType { int modified; String name; } If my pList has size of 10 and if i want to retrieve ArrayList of names for all objects in it, how do I do that? For
I have this Martian class: public abstract class Martian implements Cloneable { int id; public Martian(int id) { this.id = id; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public int getId() { return id; } publi
I tried below code, It works only for 1 array, when i try to add another, it throws an runtime exception Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.add(Unknown Source) at java.util.AbstractList.a
I have a String array like, String[] abc= new String[]{}; and my List has some values. I iterate the list and add each list element to string array. for(int i=0; i<errList.size(); i++) { abc[i] = errList.get(i).getSrceCd(); } errList.size() has 6 val
I want to show data in this format, 12-22-2011 11:00:00 [12-22-2011 11:13:39] Warning: Contact 'nagiosadmin' service notification command '/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: C:\ Drive Space\nH
The problem occurs at Element element = it.next(); And this code which contains that line, is inside of an OnTouchEvent for (Iterator<Element> it = mElements.iterator(); it.hasNext();){ Element element = it.next(); if(touchX > element.mX &&am
Sup guys. I'm writing a simple zombie game for my Java classes and I'm struck with a little problem: the Zombies are a class I made and I'm treating them on an ArrayList, like this: horda.add(new Zumbi( (int)(Math.random()* 750), 0)); Where the argum
my arraylistS in a covering arraylist behave like the same instance. i manupulate one of them with i=0; manupulate((ArrayList)theCoveringRootArrayList.get(i)); , and all the sub arraylists have become effected of the manupulation. i did my homework i
i dont't use java very often and now i got some Problem. I want to read a CSV file like this one: A,B,C,D A,B,F,K E,F,S,A A,B,C,S A,C,C,S Java don't know dynamic arrays, so i choose an ArrayList. This works so far. The Problem is: How can I store the
I have an arraylist of doubles returned by a JSON library. After the JSON parser's decode method is run, we have this in the C# locals window: Name Value Type myObj Count=4 object {System.Collections.ArrayList} [0] 100.0 object {double} [1] 244.0 obj
I am using VS2008, and ASP.NET 3.5 C# I have an array list that is populated using a textBox & button for input of numbers. After clicking the button, I need to display the highest number in the arraylist. So far I know I need a loop to compare the t
I tend to use ArrayLists of structures. It is then very easy to cycle through the list with a foreach. The problem I have is I cant use a foreach to modify the structures contents and have to use a for and messy typecasts. ((dataStructure)files[x]).n