I'm not quite sure what your goal is, the original goal seems to just turn a string of numbers into an array of ints. The code you provided looks like you are counting frequency.
I'd suggest you...
Type: Posts; User: sunde
I'm not quite sure what your goal is, the original goal seems to just turn a string of numbers into an array of ints. The code you provided looks like you are counting frequency.
I'd suggest you...
Another good book which I recommend quite often is head first java. It covers a wide variety of topics in depth. It also gives you an introduction to some more complicated concepts. I suggest you...
While thats mostly correct, when you declare the array you put the length in the brackets, a 12 item array(indices 0-11) would be declared
int[] myArray = new int[12];
To explain why it...
I am editing my post because I figured a lot of the problems out. I am now using an action which finds the selected values of 2 toggle buttons and 2 combo boxes and when they are clicked, it sets the...
I am working on building a text editor using a jtext pane, and I have run into some problems. I am fairly inexperienced when it comes to using jtextpanes, and I have read the tutorials on them,...
This code snippet doesn't show the attempt to set checkMate to anything. Are you sure you remembered to assign something to checkMate? Also, I'm sure you are aware but just in case, jtextfields...
I'm glad to have helped.
When you try and parse an integer that contains something other than 0-9, what happens? Is an exception thrown? If so, which?
Try catching that exception in the catch and do whatever you want in...
try{
//try something
} catch(/*some exception*/){
//do something as a result of catching the exception
}
read up on exceptions if necessary.
Sounds like you may want to wrap the parse in a try catch clause, and be prepared to catch a number format exception.
Why not add another instance variable to track the previous operation, you could use booleans or strings to accomplish it
This is an example of a program to recursively add two numbers.
public class Add{
public static int add(int x, int y){
if(y == 0){
return x;
}
else{
return add(x...
First off this is not recursion, you are using a loop, recursion relies on recalling the same method until some condition is met.
Your code, although not recursion is fine, except you need a main...
Perhaps you are looking for the Math.round, Math.ceiling, and Math.floor?(assuming i understand the question you have)
Inside the loop you are just continually re-assigning the array to a user input, which doesn't work since a string is not a string array. You use indexing so I assume you understand how to index...
A normal for loop takes the following form
for(declaration; condition; step)
or
for(int i = 0; i < 5; i++)
How would you make the item loop 6 times, 7, 8, 9? What part of the for loop...
One problem I notice right away is that if they guess incorrectly it will tell them if they are too low or high, and then give them the answer and ask if they want to try again. if you enter 1 your...