Skip to main content

All Questions

Tagged with
-2 votes
3 answers
119 views

Add an array of objects as a parameter to a constructor

I am working on a Java quiz application. In this I want the four answer options to be as an array instead of coding it is as Option 1,2,..4. How do I add an array of objects to the constructor? I am ...
Paramesh Athreya's user avatar
-1 votes
2 answers
49 views

Error while building a program which should output assigned domino tiles for each player in Java

So, I am a total beginner in Java. I need a program that takes a number of players as an input. Then assuming there are 91 domino tiles each with two squares with dots ranging from 0 to 12 in each ...
PabloSaint's user avatar
1 vote
5 answers
198 views

how to return a list of employee's names with the highest pay rate in java

Assume i have a valid Employee class. I create a PayRoll class with main method. ` public class PayRoll { public static void main(String[] args) { //create 6 Employee objects Employee(...
user27719723's user avatar
-1 votes
1 answer
50 views

How come I'm running into an error after all the enemies are defeated, shouldn't it have ended?

I'm making a program using java, and the particular issue I ran into was in the battle method, where the program runs into an error after all the enemies are defeated. I tried to alter it a couple ...
Idiot User's user avatar
1 vote
1 answer
42 views

GUI Java Swing . Trying to get a string from one class into a jlable of another class

I'm trying to get an output from a bubble sort algorithm (which I'm currently doing with System.out.print) to be displayed in a JLabel in another class when I'm pressing a JButton. I'm fairly new to ...
Moritz Wolf's user avatar
-1 votes
1 answer
37 views

Create Separate Class to Print Smaller and Bigger of Random Array in Java

I am completely lost. I created a Data class that generates Arrays. The Data class computes a set a of random numbers. I also made another class printing the sum of those numbers. My issue is I want ...
darth.vater's user avatar
-1 votes
2 answers
94 views

Outputting w different classes & Constructors

UPDATE: it was an issue that the file I was gathering text from had lol. Whenever I try running the output, there are multiple exceptions in everything past the welcome message that prevent any output ...
moemoe's user avatar
  • 1
0 votes
1 answer
101 views

Code Output Comparison and Correction Request

the task description class Solution { /** * @param n the given positive number * @return the square matrix of order n according to the given pattern */ public static int[][] ...
Orzibekov Yusufbek's user avatar
1 vote
2 answers
60 views

Need help assigning array to new type Employee

My code currently runs. The problem is, I miss understood the assignment and I need to arrays of type Employee (so I need an additional class called Employee). Currently, I have 3 arrays: Saves Name ...
visceralamoeba's user avatar
0 votes
0 answers
66 views

How to make a method that accepts an array from a user, separated by ";" and adds it to the existing private array in the same class

Academic assignment requirements: Create a custom method called: appendToPersonArr with these parameters: (Person[] srcArr, int mode), that accepts an array of Person[] objects and appends it to the ...
z.....k's user avatar
1 vote
1 answer
63 views

Arrays and objects

If arrays are objects in Java then why they are not initialized using syntax X x = new X();? Like if there is a class named Person, and I have to create an object of that class then I will use syntax:...
Shrey Saxena's user avatar
0 votes
2 answers
68 views

date verify with Java

I've created a class to receive an object with a date and verify by a method if the date is writen correctly. The problem is that my code doesn't work to verify the characters correctly. Here I have ...
Ademir Júnior's user avatar
0 votes
1 answer
48 views

How to remove a team name (String) from an Array read from a data file?

I am trying to make an input dialog that prompts the user to select a second team that plays the first team. The team the user selected before cannot show again and there needs to be an error check if ...
Zia's user avatar
  • 1
0 votes
1 answer
378 views

Getting error : Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 [duplicate]

I am trying to take name input from another class (i.e. from "StudentMarks.class"). I am taking all the user inputs from main class (i.e. from "StudentMarks.class"), but the ...
BekarBanda's user avatar
0 votes
2 answers
60 views

What may be the problem for finding frequency of elements in array through class leading to NULL Pointer Exception?

This code finds the frequency of elements in the array. But it is showing cannot read field because array is null. Code import java.util.*; public class Main { public static void main(String[] ...
Samik Pandit's user avatar

15 30 50 per page
1
2 3 4 5
56