Skip to main content

All Questions

Tagged with
0 votes
3 answers
1k views

Why do we initially set min and max to the first value in the array when trying to find the minimum and maximum value?

I've been learning Java for a while and I've run into a problem I can't figure out. I am currently learning arrays and how to iterate through them using loops. I generally understand how the if ...
b3jf's user avatar
  • 1
0 votes
2 answers
449 views

How do I add every array in a list with every nth element in the array

I have a function public static void sortedlist(int[] l, int r) that takes an array int[] l and returns a new array where every non-negative element in the list would be added with every element until ...
Nutnicha's user avatar
  • 269
0 votes
2 answers
66 views

How to print index of all maximum numbers without losing the index count?

Let's say I have created an array int[] maxNums = {62, 24, 54, 92, 12, 45, 75, 43, 46, 98, 23, 98}; I know how to print the maximum and its index. Here I have two repeated numbers 98, how do I print ...
Jack's user avatar
  • 19
0 votes
2 answers
51 views

how to add elements in each row seperately and print output in 2D array

Lets assume i have a 2x3 matrix where row denote student and column denote marks. eg:[[67,80,56], [32,26,31]] need to find the average of each row and assign a grade based on avg. if avg>40 then ...
VIJAYARAJ's user avatar
0 votes
1 answer
529 views

Java: For Loop iterating strangely causing out of bounds errors

I have a for loop that iterates through a string of numbers. I also have an array that is the same length of the string consisting of numbers that represent that index's max value. The code iterates ...
Petetunze's user avatar
0 votes
2 answers
381 views

For loop to iterate through user input to calculate cost?

I'm working in Java. So what I'm trying to do is, take the user input from subscriberPackage public static String subscriberPackage() { //Method to get the customers name Scanner sc = ...
DeathlySin's user avatar
0 votes
1 answer
314 views

How to loop through 2 different arrays in one loop in Java

I'm creating a method in my program that tells whether the if the user is at risk of covid through these question markers that has specific health risk categories (low, medium, high). The expected ...
Hi I'm Justin's user avatar
-1 votes
3 answers
227 views

loop through two different Arrays java

sorry if this is an stupid question or anything; but I'm having a problem looping through two different objects in java. one of them is a hashmap and the other one is an arraylist. the objects look ...
Khode Alishon's user avatar
-3 votes
2 answers
60 views

Java String Array Iteration: Is there any way to make this simpler?

Good day, I'm new to Java and have been practicing with Nested Loop iterations. I was wondering if there is any simpler way on how to do this? Especially on the part where I had to put this [j+1]. ...
shoshinsha's user avatar
0 votes
1 answer
547 views

Check that a LinkedList contains all the elements of an array

I would like to write a method public boolean containsArray(int[] arr) which returns true if all the elements of the array are in the list, otherwise it returns false. I would like to only use the ...
h4ckerlinguist's user avatar
0 votes
1 answer
38 views

I would like to display numbers in a certain way but it's off-centre

I want to display number in rows, where the number of rows is asked as user input and the number of columns is always 4. It all works fine but it's off-centre. This is my code: public class Practise { ...
vania prasad's user avatar
0 votes
2 answers
190 views

Iterating over a char array inside nested loops

I'm creating a Hangman game in Java, but I'm having some trouble with the loops I use to compare a letter to a word (char Array): public class Hangman{ static String seleccionar(){ //Se ...
Dan-code-str's user avatar
0 votes
2 answers
38 views

sorting objects into an array of elements and an array with several elements

I have to sort a list of students, depending on the specialty they applied to. My variabile for array in object is String [] specializations; The objects I introduced look like this: x.add (new ...
CristiaN Fnc's user avatar
1 vote
3 answers
3k views

Nested For Loop in Java method to check for Duplicates

I am a beginner and I have been trying to debug my code for several days now to figure out why my loop in isDuplicate does not seem to work correctly. I've scoured the site for ideas but none seem to ...
TheLC5's user avatar
  • 11
1 vote
3 answers
1k views

Generate all possible string combinations by replacing the hidden “#” number sign

My task is to generates all possible combinations of that rows without the hidden # number sign. The input is XOXX#OO#XO and here is the example of what the output should be: XOXXOOOOXO XOXXOOOXXO ...
some_cs_student's user avatar

15 30 50 per page
1
2 3 4 5
9