How can one check if an integer is equal to another in a 2D array?

How can one check if an integer is equal to another in a 2D array? int[][] board = new int [3][3]; int a = board[0][0]; int b = board[0][1]; int c = board[0][2]; int d = board[1][0]; int e = board[1][…

No exception raised for referenced unassigned array element containing an object

MRP class B { static int v; public B(int i) { System.out.format(“Constructor called with value %dn”, i); v=i; } } public class A { static B[] c; …

Find all strings with smallest length in an array

I want to return the smallest values from my words array Finding the shortest word is easy but I am not sure how to return a new array with the shortest words. public class Test{ public static …

Java OOP; creating array of objects

I’d like to create an array of objects where 3 objects are from one class, and a 4th is from second class. In the first class I did the following: public class Pupil { public int n= 0; …

Merge lines that share a word-link

so I’m having a small problem in java. I have something like “Victor Fleming” “Gone With” “With The” “The Wind.” So what the sentence should actually look …

How to solve Cannot invoke “String.compareTo(String)” because “[]” is null?

import java.util.Scanner; public class Search { static Scanner scanner = new Scanner(System.in); static Scanner kb = new Scanner(System.in); static Scanner kb2 = new Scanner(System.in); …

Read integers from a text file and store them into an array in Java

So I have a text file with integers in it like this: 20 25 3 239 6 184 211 155 245 25 13 73 73 82 70 164 164 102 193 44 205 250 145 102 95 83 152 168 148 193 54 228 86 244 10 26 181 106 53 209 249 21 …

Can’t use array of objects

I have a Main and a Cars classes, and I am trying to create an array of Cars and have it like this: public class Cars { protected String brand; protected int price; protected Cars[] list; …

Swapping elements in an array Java

I am working on a classes challenge in school. We have to great a Boat class and Harbor class. I have gotten every test to work except the final test of where boats are parked in the Harbor. The …

traverse an array in GUI Java

I am doing a questionnaire with questions and written answers. I need that when adding the answer, press the main button, tell me if it is correct or not and show me the other question of the array, …