Skip to content
Advertisement

Tag: arrays

Way to scan contents of a singular array index?

There is an array in my code that includes the names to random items delimited by a /n (i think). the splitLines[] array is an organizational method that collects strings and integers separated by a delimiter in a file. The file is formatted as <<Prize’s Name 0>>t<<Prize’s Price 0>>n <<Prize’s Name 1>>t<<Prize’s Price 1>>n My goal is to assign each

how to compare 2 set values in the same arraylist in java

I have an arraylist of employees. Within this the id and name are non changeable, while the hours contracted and planned are changeable. I have managed the first 3 questions stated below, but stuck on the last one. Besides the 3 Classe below, i also have the Class Workspace. I have the Class Employee. This exends to Class Specialist And

How to use arrayList sort and manipulate the vlaue

By using Java 11, I am trying to find the average value inside the ArrayList. The algorithm i want to develop is ((value inside list/maximum value)*100)/length of list). I got number format runtime error while I run the program. java.lang.NumberFormatException is the error i got. enter image description here Answer I find two issues with the code above: The parsing

Returning an int array in Java

So I need a script that returns an array of a text document. The document is all numbers. Everytime I try to run it I get this message “This method must return a result of type int[]” this is under the checker part. I am trying to return it to another class so that I can use the array for

Getter, Setter & NullPointerException

Firstly, I am trying to assign the value for array I initialized locally. The class type of the array is stored inside another class and the variable is private so I am using getter and setter to set the value. But it showing “Exception in thread “main” java.lang.NullPointerException at room.Test.main(Test.java:26)”, below is my code for the test.java: Below is the

An efficient way to check index out of bounds

I have an n x n 2D array, and need to connect random points to four neighbors (sorry I added the picture, but it seems one has to click on the link for the image to show). Click to see the image I would like to use code like this: The problem I am having now is the index out

Reversing digits in 2D array

I was trying to reverse the numbers in this 2D array, but I happened to be reversing only first and the last numbers. So far I have done this, but don’t know where is the mistake and how to fix it, so that every digits are being reversed, not just first and the last: Answer Ok, here is another way

Advertisement