String[random int]
Type: Posts; User: theoriginalanomaly
String[random int]
Its cause your spaces. You split the first string into "5 ", and go through both characters. Space is not equal to a number so your valid is set to false. Then it goes to the next loop, and sets...
That is a lot of closing brackets at the end. It is hard to tell with it unformatted, but I'd suspect you need to clean up and check your brackets.
Your Radio buttons are responding, but you have not programmed them to do anything. The only programming you have of them is in the constructor, which gets called once and never again. You need to...
I think probably it is because, when you divide an int it rounds down to the nearest whole number.
--- Update ---
What is the width and height set at?
How are you passing the Graphics object? Why are you not using a JPanel? Creating the Demo Application (Step 1) (The Java™ Tutorials > Creating a GUI With JFC/Swing > Performing Custom Painting) has...
...spoonfeeding removed
You could use a HashMap, and generate strings.hashCode() as the key. This would eliminate duplicates. And to get an array Collections<String> c = hm.values()
Object[] array = c.toArray()
If you are completely new to it, arduino's might be a good place to start. Arduino - Introduction
I imagine you are trying to plot a Sierpinski Triangle Fractal
public void paint(Graphics g)
{
super.paint(g);
int i = 0;
If you read through the link Copeg supplied it answers the question. The problem isn't the for loop, it is a problem with your variables.
new Thread(red); // Red or signal does not implement Runnable
// Anonymous Thread and Runnable method
new Thread(new Runnable(){
@Override
public void run() {
// Dowork;...
In my interpretation, Object is just a generic name for a class. I think you create a class with a field variable String/Date/Rectangle, that implement Comparable<CLASSNAME>. Then you need to...
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Your Methods and Fields are static. Static XPosition, YPosition mean that there is only 1 for the whole class. You are drawing both squares, but the second square you draw is overlaying the first...
That is not correct. The initial values of the array are all 0's so it checks all 10 numbers to see if they match. Here is an example output after the first roll.
----------------
d1: 4
d2: 6...
You are calling the index "System.out.println("index is: " + sumArray[i]);" that is the value you want i. Also, you have the check running everytime you fill the index so it is checking a bunch of...
instead of break, you could break out of the first loop by i = sumArray.length -1;
--- Update ---
Now that I think about it. It would be more efficient to make the second for loop
for...
for (int i = 0; i < sumArray.length; i++){
for (int j = sumArray.length -1; j >= 0; j--){
if (( i != j) && (sumArray[i] == sumArray[j])){
System.out.println("You win!");
...
By removing the "How can" and the "?" from your last sentence.
You are assigning the values before the loop. Then going through the loop, with those assigned values.
You didn't remove the semicolon from the end of the for loop. for (trial = 1; trial<=500;trial++) no semicolon. Other then that, you are sending the same numbers through the for loop, so even if it...
in the for statement you need to separate with semicolons. for (color = 1; trial <=500; trial++) and not put a semicolon after the parentheses. In your if statements, you want to write != not...
getters and setters are what they are usually called. Instead of using a constructor, you have a setMethod() and a getMethod(). At least that is one way. squareRed.setXposition(64), or...
That is a lot of classes. Usually you wouldn't want that many classes that didn't do too much, I'm not sure if it is an assignment where you are supposed to have that many classes or not, but it can...