I have some String method with two for and if: And I still try to change this implementation to some stream. Is it possible in this case? I’ve tried many options, but I have a problem with indexing (index++;) and then with filter in tableCells By.tagname. I think that is it not possible to change that full method to stream,
Tag: for-loop
how do i find the values of A,B and C in java
given the following values X,Y,Z, such as (0≤X,Y,Z≤10000) with considering the following three equations : a+b+c = X abc = Y a^2 + b^2+ c^2 = Z i need to find values of a, b and c, I wrote something like this in java: but its a naïve solution because the values of a,b and c can be zero, positive
Two sum return statement returns nothing
I’m trying to attempt a problem where I must add two elements in an array to equal a target integer value. I think my code is correct and will return the desired target however the return statement is not returning any value. why is this and how can I fix it? Thanks Answer break is wrongly used. Also, you have
Can I run a while loop inside a for loop? [Java] If so, how would I do it in this scenario?
Im doing some simple maths using loops and my task is as follows: “Given an integer,N , print its first 10 multiples. Each multiple N * i (where 1 <= N <= ) should be printed on a new line in the form: N x i = result.” My input has to be : My output: Sample Input: Sample Output:
Invert incrementing triangle pattern
I am writing some code that creates a incrementing number right angle triangle that looks something like this: I am unsure on how to make my code output a triangle to that shape as my code outputs the same thing except inverted. This is the code I have: My speculation is that instead of incrementing some of the values I
Game Of Life game: Check 2D array 8 closest surroundings; ArrayIndexOutOfBoundsException issue
I have encountered this problem and i couldn’t find the solution. There is a 2D array with only zeros and ones in it (the size of the array doesnt really matter, i worked with 10×10). Zero means dead and 1 is alive. I double for looped this to check the elements sorroundings and when it sorrounded with other “cells” the
How do I fix it to output what I want to output?
I recently started coding in Java, I just started a week ago. The previous post was deleted because I did not specify it enough, I am sorry for that. I’ve been having troubles with for, do and while …
Trying to output 0 1 2 3 8 5 6 14 8 9 using a for loop in Java [closed]
This is what I have so far: for (int i = 0; i<= 9; i++){ int output = i; if (i % 4 == 0){ output *= 2; } System.out.print(output + &…
How do i pass variables into methods – java [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I need to use a variable from one method in another. Here is the code: Here is where it needs to be used: my current
Find all matching elements in Array – Java
At the moment my code is only giving me the first matching result. The user inputs their desired room price and at the moment it will only display the first match. In the case the user inputs ’60’ to the console it should display 3 results. I imagine i’ll need another forloop and if statement after it prints to the