Is a string array with 500-1000 words read out of a file possible? Where can I get such a file.
Type: Posts; User: Gugubo
Is a string array with 500-1000 words read out of a file possible? Where can I get such a file.
If I wanted to make a game like Scrabble in Java, how could I include all the words?
Is there a way to import them or so? How do I do that? Is this even possible?
I tried your suggestion in post 4, but apparently I typed it in a bit wrong.
Tried it again and it works. Thanks!
Maybe I'll rephrase.
So this is my code:
String[] stringArray = {"hello","world","test","whatever"};
System.out.println("stringArray: "+ java.util.Arrays.toString(stringArray));...
Eclipse gives an error: "Array constants can only be used in initializers." in this line:
stringArray = {"banana","fish","tree","apple"};
How can I change a complete array when it's already initialized?
Can I change this array:
String[] stringArray = {"hello","world","test","whatever"};
to this:
...
This:
double test = 100/3;
System.out.print(test);
gives as output 33.0. Isn't it supposed to output 33.3333...?
Am I missing something?
yep, doing that now already. Apparently I forgot about arrays. Thanks anyway.
What's the easier way to get a random string?
At the moment I would use:
Random number = new Random();
numberR = number.nextInt(2)+1;
if (numberR==1){
System.out.println("Hi.");
}
Nevermind
Glad, I could help. :)
You forgot the dot between System and out.
Also post code inside code tags:
import java.io.*;
import java.util.Scanner;
class Main {
public static void main (String[] args) throws...
It's only console. Thanks, I'll try to use JOptionPanes.
How could I create this programm: If you start it, a loop tells something (say every 5 seconds) until you type in 'stop'.
The problem is, if I type in .nextLine(); it checks every time the loop...
So I've got the following code:
import java.awt.*;
import javax.swing.*;
public class testframe extends JFrame{
private JButton play;
maybe... May I ask what's an IDE?
It would be realy useful to just type in jumptoLine(12); and it goes to that line. Now is there something to do so?
Thanks for helping me, GregBannon, but I hadn't read your comment since now. And by now I already know the equals method. I btw changed the programm so it auto repeats itself after you got the right...
Thanks :)
Helped me!
if (x = y != z)
tests if x is equal to y OR z.
How do I do this for .equals?
like:
if (x.equals("Hello" or "World")
I didn't want to copy it, because it's so long...
The programm runs fine until I get the number right. Then the conosle outputs:
Again? Type in yes or no.
Again? Type in yes or no.
...
So I wanted to make a simple number guessing game, which worked fine. Then I wanted to add a play again function, but... I get errors. Why? Here's the code:
import java.util.*;
public class...
thanks :) you really helped me out a lot.
now that's not important, but how long do you think would/will it take to learn java until I can create a small game?
.