Search:

Type: Posts; User: sunde

Search: Search took 0.10 seconds.

  1. Replies
    1
    Views
    1,777

    Re: Parsing many Ints from a user input String.

    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...
  2. Replies
    8
    Views
    18,116

    Re: Best Book to learn Java

    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...
  3. Replies
    4
    Views
    1,374

    Re: Question on arrays.

    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...
  4. Replies
    1
    Views
    1,837

    Re: JTextPane questions.

    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...
  5. Replies
    1
    Views
    1,837

    JTextPane questions.

    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,...
  6. Re: Assigning an 'int' from a JTextField to a variable...

    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...
  7. Replies
    7
    Views
    1,527

    Re: Command For Rolling Random Number

    I'm glad to have helped.
  8. Replies
    7
    Views
    1,527

    Re: Command For Rolling Random Number

    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...
  9. Replies
    7
    Views
    1,527

    Re: Command For Rolling Random Number

    try{
    //try something
    } catch(/*some exception*/){
    //do something as a result of catching the exception
    }

    read up on exceptions if necessary.
  10. Replies
    7
    Views
    1,527

    Re: Command For Rolling Random Number

    Sounds like you may want to wrap the parse in a try catch clause, and be prepared to catch a number format exception.
  11. Replies
    1
    Views
    1,381

    Re: Help me with this code.

    Why not add another instance variable to track the previous operation, you could use booleans or strings to accomplish it
  12. Thread: Recursion help

    by sunde
    Replies
    3
    Views
    1,641

    [SOLVED] Re: Recursion help

    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...
  13. Thread: Recursion help

    by sunde
    Replies
    3
    Views
    1,641

    [SOLVED] Re: Recursion help

    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...
  14. Replies
    2
    Views
    1,529

    [SOLVED] Re: Help Again Last Part of my Problem :(

    Perhaps you are looking for the Math.round, Math.ceiling, and Math.floor?(assuming i understand the question you have)
  15. Replies
    4
    Views
    2,304

    Re: How to store 10 inputs in an arraylist?

    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...
  16. Replies
    7
    Views
    2,384

    [SOLVED] Re: Using a For loop for repetition

    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...
  17. Replies
    1
    Views
    1,260

    Re: What's wrong with my code?

    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...
Results 1 to 17 of 17