I’m making a method called fillList. The method will require an arrayList in order to work and the output will be void. What the method is supposed to do is to fill the gaps between the numbers of the List. Example: Input: Output: The code I have so far is this: My idea was to add 1 to the value
Tag: for-loop
How to fill an array with a new row in Java?
So what I have so far is a randomized board containing numbers 1, 2 and 3. The board is 6 * 10. (So 6 Columns and 10 rows). The plan is when the user gives an input, a new row of randomized numbers should be added to the board. The thing is that the 2D array will be 6 *
I am trying to add two float arrays into a third array but receive only zeros
I want to use 3 looping structures for three different arrays. The first loop generates numbers 0 to 49. The second loop takes the first loop numbers and squares them. The third loop holds the sum of all 49 values. If I put it all in a single statement, I get exactly what I want, except it doesn’t fill each
Im trying to make a “graphic” printing a certain amount of characters based on array values java
I have to make a code thats contain a method that takes a vector of integers as a parameter and, from their values, prints a horizontal bar graph on the screen. I Just cant print the amount of characters with the value of the string. Rigth now i have a list in a method: And the output should be like
Codingbat challenge: sameEnds Stream API Solution
Given the task sameEnds from CodingBat: Return true if the group of N numbers at the start and end of the array are the same. For example, with {5, 6, 45, 99, 13, 5, 6}, the ends are the same for n=0 and n=2, and false for n=1 and n=3. You may assume that n is in the range 0..nums.length
Nested for-loop problem with descending number
I’m trying to figure out how to complete this problem. I’m shooting for: and I have the following code, which gives me this: I think I’m close but can some one help? } Answer I think the problem is with the logic you used. I made an algorithm inspired by another idea, maybe it will help you. I am sure
Printing multiple user input from a loop
This is a two part question. 1) how do I print all userinput if the loop runs more than once , I am aware the old string assigned to the variable gets erased each time. 2) how do i calculate the total task duration across all tasks for the amount of times the loop runs. thanks. Answer You can create
Find the first Recurring letter in Java
I wrote the code as follows but it doesn’t return the first recurring letter properly. Example: In the word “statistics” the recurring letters are s, t, and i. But the letter t recurs sooner than the letter s and i, but my program returns s instead of t. What do I need to do for it to return t, using
Counting Letters & Words in a Math Equation String
So, I have written a method named varCount(), shown below, that would count the number of letter variables in a math equation. This method is made inside a class, so the getter method of the private equation string attribute was used here. One example of what should result from this was, if you are using the method on a string
Do a task with interval in a loop
I already saw many question here but nothing worked for me. I wanted to set the text in a text view after every 1 second. This is what I tried: This does the task immediately and only the last number is seen. Then this: in this the screen shows blank white and after 90 seconds, I see the last number.