Skip to main content

All Questions

Tagged with
-4 votes
1 answer
71 views

Making a List with Arithmetic Progression [duplicate]

[Doing an assignment where I have to have to run the formula a(n) = 2*n - 5 (n>=1)] 100 times and have those in a list so that I can grab terms and compare and bunch of other stuff. This is what my ...
Jide Fadairo's user avatar
0 votes
1 answer
52 views

How Matrix Elements are getting changed?

My Question is when I am initializing matrix2 with case1 approach I am getting the right answer, but when I am initialising matrix 2 with case2 approach I am getting wrong ans. The if condition is ...
Deepak Kumar's user avatar
0 votes
2 answers
76 views

For loop condition not working as per expectations

I am writing a code in this code I have to find the minimum steps which can take me from index 0 to index n-1. nums[i] represent the maximum jump I can take from ith index. (Reference leetcode Q45 ...
jainyashit's user avatar
-1 votes
1 answer
82 views

How can I get each of my objects to "bounce" off one another when they collide?

Here is my program that has a run method which runs the simulation. import java.util.*; public class Game{ public static int size; public int numObjects; public static int speedX; ...
Tijil Saka's user avatar
0 votes
2 answers
72 views

trouble with array usage

This is my prompt: Write a program that reads an arbitrary number of integers that are in the range 0 to 50 inclusive and counts how many occurrences of each are entered. Indicate the end of the ...
arikaku's user avatar
2 votes
2 answers
46 views

how to print an array forward and backward based on boolean flag true/false using single for loop in java?

Arr = {"apple" , "orange" , "pineapple"}; If (boolean)flag = true : o/p - pineapple orange apple Else o/p - apple orange pineapple I tried using while, how to implement ...
Suravi's user avatar
  • 29
0 votes
1 answer
54 views

How do I detect the highest z-level object in a 3d array?

I'm working on a simple game in Java (think Rogue 1980), and have a tile rendering system in the draw() method. I'm transitioning from a 2d array for tiles to the 3d array so I can have tiles persist ...
Lum1te's user avatar
  • 3
0 votes
1 answer
59 views

Win condition in game not working. Trouble finding subsequent elements in 2D Array

I have an issue with my Gomoku game win conditions, in which I iterate through the 2D array looking for symbols related to each player. I have the typical nested for loop that goes through the array ...
Steamly's user avatar
  • 15
0 votes
1 answer
68 views

How to fill array by columns, not rows?

I need to make a 2d array 10 by 10 that looks like this: 0 45 44 42 39 35 30 24 17 9 0 0 43 41 38 34 29 23 16 8 0 0 0 40 37 33 28 22 15 7 0 0 0 0 36 32 27 21 14 6 0 0 0 0 0 31 26 20 13 5 0 0 ...
faeton's user avatar
  • 3
2 votes
3 answers
282 views

Looping through an array of strings and counting the number of times a vowel is in each word

Hi I'm trying to loop through an array of strings in count the number of times a vowel is in a word from the sentence. String st = "Hello Today Is a lovely day"; String[] st1 = st.split(&...
Dwayne's user avatar
  • 21
1 vote
1 answer
2k views

Tic Tac Toe game beginner level

i am new to programming and i was doing a tic tac toe game on beginner level but i can't manage to get my code to repeat when user puts invalid value. Instead of re-asking the question it ends the ...
Gkdnzx707's user avatar
0 votes
3 answers
120 views

How can I check duplicated words within an Array and count them?

I just started programming with JAVA 2 months ago and currently I'm facing an exercise which I don't find the solution for. Until now I control (kind of) the following structures: if (else), do while, ...
gamlas's user avatar
  • 3
0 votes
0 answers
53 views

In Java, how do I check if a specific element appears in an array? [duplicate]

Please bear with me, I am very new to Java. I have created an array that is created from two text files using File Reader when the program is run, I need to check if an element in the list is a ...
EkatS's user avatar
  • 11
0 votes
2 answers
113 views

Java - Iterate over an odd length String, two consecutive characters at once

I was reading a file(using BufferedReader & FileReader) line by line and needed to get two successive characters & store it in two distinct variables for every iteration of the loop, but the ...
BeyondeR's user avatar
-1 votes
1 answer
73 views

Which loop which is best for iterating for strings in java [duplicate]

I always use normal for loop ie. for(int i=0;i<s.length;i++){} for iterating through string although its simple way to iterate through string can anyone suggest me other type of looping method ...
Satish Chauhan's user avatar

15 30 50 per page
1
2 3 4 5
108