0
votes
0answers
5 views

else statement printing multiple times - array loop

I want my code to loop through an array and only give the user an option to delete a student only if there are values in the array. If all the array values are null then I want it to print out a ...
0
votes
3answers
12 views

Printing temp to display an int array in reverse only shows the first two numbers that were entered?

(Java beginner) I came up with a code that would display an int array in reverse and although I know there's probably a better way to do it, I think this logic should work: for(int i = 0, j = ...
0
votes
0answers
14 views

How to change bits in byte[] Array that has letters in Java?

public static byte[] encryptedPas; Hi, I have a byte array like the above which contains something like 'B@68cc40e6' when printed after encrypting a text, I'm trying to change single bits in the ...
-4
votes
3answers
26 views

ArrrayList use for user defined Class

I'm facing a problem in ArrrayList. Please help. A test program in which has two data type String and int, when add item by add method it give me error; if Integer is add The method add(int, Test) ...
1
vote
2answers
38 views

Program Compiles, but array out of bounds when ran?

My code compiles fine, but when I run it I get the following error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Sudoku.(Sudoku.java:20) at ...
-3
votes
1answer
28 views

Most Efficient way to form a word from Character Array containg aphabets from A to Z? [on hold]

I have to form a String by picking each character from a character array. e.g - word to create is "WAFFLE", So one would loop through character array searching for 'W', then 'A', then for 'F' & so ...
-4
votes
2answers
43 views

Filtering array in Java [on hold]

By using a java.util.HashSet<Double>, write a method double[] negated(double[] a) that takes a List, a, as an argument and returns a list containing only the elements, x, such that -x is also in ...
0
votes
3answers
30 views

How to add another object to an object array

i have java code (array of objects) Items[] store = new Items[] { new Items(...) , new Items(...) }; What is the standard method to append to this store array. I am trying not to use ArrayList ...
0
votes
2answers
39 views

Java - Arrays: How do i find the number that has a similar digit most times?

I am having a problem with one of my tasks. I was asked to build an array that the user will enter the length of. At the end, the main goal is to print the number that has the largest frequency of any ...
3
votes
4answers
67 views

Math and Arrays

I'm new to java and still learning. I am having one heck of a time trying to figure out how to create this program. I have tried multiple ways and spent about 4 hours now trying to get this to work ...
0
votes
1answer
31 views

How to add a runner to an array of results

I have been trying to figure out how to add runner information into an array of runner information. It should contain at most 100 runners. This is part of a larger project that must fulfill these ...
0
votes
2answers
30 views

Java - Using parallel arrays to find common frequent number/s

I have an array and have already sorted it. I want to be able to find which numbers repeat. Following that, I want to be able to count how many times these numbers repeat. For example in a list ...
-3
votes
1answer
48 views

how pass array to constructor java? [on hold]

How pass array to Constructor with one parameter integer I want to save all the value of array in a1 when use this code : //Constructor,,int a1 welcome(int…a) { for(int b:a) { ...
-1
votes
1answer
27 views

frame won't repaint after adjusting string

I am not sure what I am doing wrong to get my frame to change when I have the user input data and press enter to adjust the string that was set to display on the frame. I am just going to include the ...
0
votes
5answers
58 views

How to dynamically increase size of a 2D array

I already know how to make a fixed array, if I know how many elements I have. For instance, for 7 elements I do something like int array[2][4]. But what if I have 0 elements at start(which means the ...
0
votes
1answer
61 views

Deleting an item from an array. (Java)

I'm working in Java right now, and I'm attempting to make an array copy itself into a temporary array, and then overwriting again with a new list, however the code isn't functioning. ...
1
vote
2answers
56 views

Return array to method

I have a method to total up average results which calls another method which stores an array of the results but I seem to having trouble returning the array: Array code: static double findAverages() ...
1
vote
2answers
53 views

Attempting to find minimum value in array

I have an array with ten values and I am looking to loop through the array and store the lowest value in a variable but I keep getting 0.0 outputted even though the smallest number is 3. Here is my ...
0
votes
1answer
32 views

Multi-dimension queryable HashMap Array

I have a CSV file that I'd like to store as a Java object. I would like the name of the columns to be the first dimension of the array, and key pair values the second dimension of the array. I've ...
-2
votes
4answers
60 views

void error in Arrays.sort() in java

String text1 = "check"; char c[] = Arrays.sort(text1.toCharArray()); Output: error: incompatible types char c[] = Arrays.sort(text1.toCharArray()); required: char[] found: void ...
0
votes
3answers
58 views

Need some help in Java with array constructors and comparing results from array

Hello all who read this, I'm still learning Java but i can't figure out how to put results from another class into an array in the main class and then write a method that compares certain results ...
1
vote
3answers
44 views

Find largest average set of results in array

I have a 2D array and I want to find the largest average set of results, so far I can calculate the average of each set of results but I'm not sure how to select the biggest from the output. My code: ...
-1
votes
2answers
80 views

sorting in quick sort algorithm

This is my program to sort list or array in quick sort algorithm the pivot in the midst of array how can chose the pivot randomly?......................................................... public ...
8
votes
1answer
156 views

Java / C# - Array[][] complexity task [duplicate]

I'm dealing with some problematic complexity question via my university: Program input : A n x n Array[][] that is filled with either 0 or 1. DEFINITION: Define k as a SINK if in the k row all the ...
1
vote
4answers
72 views

Delete object from array

I've got this constructor in the class Music: protected String Title; protected String Autor; protected String Type; protected int Code; public Music (String title, String autor, String type, int ...
0
votes
1answer
52 views

Method for converting boolean array to binary java [duplicate]

Is there already a specific method for converting a Boolean array to a binary array or would I just need a for loop?
3
votes
4answers
100 views

Search string in two dimensional string array java

I have a two dimensional string array look like this: The first column contains characters of many strings, other columns are extra data for character. I want to search a string (maybe change to ...
0
votes
4answers
56 views

How to sort the arrays in ArrayList?

I have ArrayList it contains so many arrays, each array contain first name, last name. now I want to sort the list based on the last name. Example: ArrayList<String[]> list=new ...
-1
votes
2answers
39 views

get a certain part of a hashmap [on hold]

I'm converting a hashmap into 2 arrays, an integer array, and a String array. I'm trying to do this to make it usable, my HashMap looks like this: HashMap<String, String> I'm converting the ...
1
vote
6answers
48 views

What is the use of converting Array to ArrayList if it is not supporting adding or removing element?

I have tried the following and saw it throws java.lang.UnsupportedOperationException when I try to add new element to it. Basically I tried to convert an Array to an ArrayList and tried to add new ...
0
votes
2answers
65 views

I'm making a 24-hour clock

I'm making a 24-clock. I have the code below. My problem is that the int[] time is equal to [0, 0, 0] and prints it out every iteration. Some more information that might help you. I have the Array ...
0
votes
3answers
36 views

Copy some elements from an array of double to an array list of double

I have the method threshold(double[] a, double x) that takes a list (a) and a numerical value (x) and returns all the values within a that are greater than x. I am having trouble adding the elements ...
-1
votes
1answer
22 views

Battleship Project Problems

public class Basic { public static int numGuess; public int guess; public int numHits = 0; private static int[] ships; private boolean hitShip; public static boolean ...
1
vote
0answers
41 views

How to reference the indexes of an array from another class or object?

So I'm working on creating the game of Monopoly, I'm in way over my head but I'm willing to learn. Anyways my problem is that I create the array with size based on user input (holds the different ...
0
votes
1answer
15 views

Java - Apostrophe error when reading words from text file into an array

I am using the following method to read words in a .txt file into an array. import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import ...
0
votes
1answer
35 views

Using and manipulating arrays without Array.replace Array.copy

Ok well I posted a question with a small portion of my code. I realized that it would be easier for people to answer if they could see the entire code. I get nullpointerException when I run the ...
0
votes
2answers
34 views

Codemodel Java Library - Initializing 2D Array

Just trying to declare and initialize a 2D array using the codemodel library by Sun but I'm having some issues. I've tried: JBlock.decl(model.LONG.array().array(), "arrayName", ...
0
votes
2answers
34 views

Array NullPointerException

I'm learning arrays for the first time and have been unable to figure out why i keep getting errors. This is my constructor for my class called Grades. public Grades(float [] g){ for(int i = 0; ...
1
vote
1answer
25 views

NullPointerException when filling a 2Dimensional array with a vector

I have a bit of a problem that I cant seem to make work. Im trying to fill an array with a vector in a for loop(as the size of the vector will change over time). I create my vector like this in a ...
0
votes
3answers
39 views

Java HashSet to array

I'm trying to convert a HashSet to an Array of Doubles. Yes I have a main method and class defined, I've just included what I've imported as well as the code for this specific function. This is the ...
-1
votes
0answers
69 views

Array Issues: tester and main class

I'm still new to arrays. I know I'm doing something wrong in regards to the array's tester or main method. Here is program instructions to make. MY QUESTION IS "What am I doing wrong with calling ...
0
votes
1answer
18 views

Output to file from arraylist not working - java

I'm trying to create a program that outputs a bunch of integers from an arraylist to a file, however all I get is a bunch of question marks in the .dat file. Can anyone see what my problem is? ...
0
votes
2answers
38 views

How do I access object data, where the objects are in an array using a for loop?

I'm creating the game of monopoly, star wars edition for fun, not for homework :) Anyways I'm prompting the user to input how many 'human' players they want out of 4 players in total. Then I use a for ...
-6
votes
2answers
47 views

java array printing the repeated numbers , array in the array [on hold]

Please could you tell me how its work in section (g[ss[i]]++;) and tell me the sequence of output in java class A{ public static void main(String []a){ int ...
0
votes
1answer
22 views

array sort multidimensional array to match second array

I have a single demenational array with student names and a 2D array with student marks, I can sort the names fine but I cannot get the marks to match (as they have to stay in the same order). Here is ...
2
votes
2answers
26 views

Removing duplicates scale up error

I am trying to remove duplicates from an array. What I have works on an array size of 10([11]). Then i had to scale it up to 5000([5001]). I thought this would be very simple. It compiles but when I ...
0
votes
2answers
53 views

Can't properly access array using another class

I'm trying to get the values of outputArray that were initialized in the class LightsOutPuzzle in my class, solve. But after printing the elements of the array 1) before calling the class solve in ...
0
votes
1answer
59 views

Array delete - last entry duplicated

I have code which deletes an entry from an array and then moves all the elements down one index so the empty space will be left at the end of the array. The problem is that the last entry in the array ...
0
votes
1answer
48 views

How many arrays will be initialized executing code? [on hold]

How many arrays with size 1000 will be initialized in memory? Integer[] intArr = new Integer[1000]; List<Integer> list = Arrays.asList(intArr); List<Integer> list2 = new ...
2
votes
2answers
35 views

3D array (1D flat) indexing

I am using a coordinate system x (width), y (height), z (Depth) Just to clear confusion if there is any x & y are a flat plane and I am using Z as elevation. I am going to be accessing the array ...

15 30 50 per page