Search:

Type: Posts; User: Blackrabbitjack

Search: Search took 0.08 seconds.

  1. Replies
    4
    Views
    1,801

    Re: Picking Random Element from Array

    public void randomGen(String[] x) {
    int rand = rangen.nextInt(x.length-2);
    JOptionPane.showMessageDialog(null, "Randomly chosen word is: " + x[rand]);
    }

    For anyone...
  2. Replies
    4
    Views
    1,801

    Re: Picking Random Element from Array

    Would this be the proper way to use this utility?


    public void randomGen(String[] x) {
    Random rangen = new Random();
    int rand = rangen.nextInt(x.length-1);

    }
  3. Replies
    4
    Views
    1,801

    Picking Random Element from Array

    Not too sure if this is the right place to post this, so if it isn't, I apologize. Still figuring out my way around here.

    Anyways, what is the best way to grab a random element from an array?...
  4. Replies
    1
    Views
    1,123

    Re: New to Forum.

    Welcome! I'm fairly new to these forums as well, and am approximately at the same level of programming capabilities as you are. Been toying with java in a lot of my college courses over the years. If...
  5. Replies
    20
    Views
    1,843

    [SOLVED] Re: Can't reassign boolean value!

    I will agree with Norm. If you only need a quick variable for a function inside a method, instantiate it within the method. Otherwise, if you need multiple methods to use a single variable, or a...
  6. Replies
    20
    Views
    1,843

    [SOLVED] Re: Can't reassign boolean value!

    I was confused by what Norm is trying to say when he posted it in my post. Basically, whenever you want to see if a variable is being assigned to something, use a println to say ("Assigned variable...
  7. Re: Begginer : help would be much appreciated for this exercice!

    Jumping the gun on trying to make the GUI is always a bad idea. Make your methods work and your logic correct before you try to make it look pretty. What compiler are you using? Also, it might be...
  8. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    varlib.tableA[i] = readIn;

    Stupid mistake, but the code works. Thanks for pointing me in the right direction!
  9. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    public void popTableAArray() {
    String readIn;

    try{
    BufferedReader br = new BufferedReader(new FileReader("tableA.txt"));
    System.out.println("For...
  10. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    public void popTableAArray() {
    String readIn;

    try{
    BufferedReader br = new BufferedReader(new FileReader("tableA.txt"));
    for(int i=0;...
  11. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    Placed the file in the root directory, and changed the println to show the values of readIn. Still outputs my Else first, and still shows the values of the txt file as null. There are no other files...
  12. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    You're asking the wrong guy. What are you talking about "where the null file is?" Would it not show a IO Error if it loaded a file that doesn't exist? My pathing is entirely correct. I'll try putting...
  13. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    This code:

    public void popTableAArray() {
    String readIn;
    try{
    BufferedReader br = new BufferedReader(new FileReader("db/tableA.txt"));
    for(int i=0;...
  14. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    There is only one text file in the specified directory. It's formatted as such

    Sleeping
    Tired
    Hungry
    ....

    (those are the actual first three lines of the file) Is there something crucial I'm...
  15. Replies
    18
    Views
    1,563

    [SOLVED] Re: Array Population via .txt File

    The oracle document states that reader will return:

    A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached
    ...
  16. Replies
    18
    Views
    1,563

    [SOLVED] Array Population via .txt File

    Alright, I've been plugging away at this code for quite some time. I finally felt it necessary to seek assistance in an online forum, as my JAVA mentor is away for the time being.

    My idea is to...
Results 1 to 16 of 16