Search:

Type: Posts; User: javaiscool

Page 1 of 4 1 2 3 4

Search: Search took 2.34 seconds.

  1. Re: removing special characters from a string, and help finding an extra space in string output

    /* append the letter @ each index in firstLetters[] array to the end of
    each word @ ea. relative index in sentence[x] array */
    for (int x = 0; x < sentence.length; x++)
    {
    if...
  2. Re: removing special characters from a string, and help finding an extra space in string output

    Vielen dank, aber es hat nicht funktioniert!

    I tried



    if ( firstLetters[x] != 0)


    and still got the extra space output after "a".
  3. removing special characters from a string, and help finding an extra space in string output

    PROBLEM SOLVED.

    Can someone find the error in my code that's creating an extra space in my output sentence, "a ay" ? It should read "aay" . I don't see it. Also, how would I remove the "." from...
  4. compile errors when creating a 2nd array the same size as 1st array

    Sorry, the title is wrong. I have a different problem, as described below.
    UPDATE: PROBLEM SOLVED, QUESTION CLOSED.

    How can I use String methods on strings within an array? I am getting an...
  5. Replies
    10
    Views
    148

    Re: How to read a string into an array?

    Wow. Thank you. I didn't even import java.util.Arrays.toString, and my program still compiled and executed. Weird.



    --- Update ---

    Got it. .substring(1) to remove the first characters of...
  6. Replies
    10
    Views
    148

    Re: How to read a string into an array?

    This is what I tried.



    public class a5main
    {
    public static void main(String args[])
    {
    String[] sentence = "This is a sample sentence...".split(" ");
  7. Replies
    10
    Views
    148

    Re: How to read a string into an array?

    From: String (Java 2 Platform SE v1.4.2)

    So, I see that regex is a delimiter. Now, I don't understand this code:



    public String[] split(String regex)


    Where in that code is the string...
  8. Replies
    10
    Views
    148

    Re: How to read a string into an array?

    I found this on Stack.

    "The easiest and best answer I can think of is to use the following method defined on the java string -

    String[] split(String regex)

    And just do "This is a sample...
  9. Replies
    10
    Views
    148

    Re: How to read a string into an array?

    So I can use the split method defining substrings to extract from the main string? Would I import java.util.* and create a Matcher object to hold whitespace? I'm still lost..
  10. Replies
    10
    Views
    148

    How to read a string into an array?

    I'm looking at the Oracle doc for strings and trying to figure out how to read a string, example: "I have a dog." into an array, wich each word as a separate index of the array, a word defined as a...
  11. Re: How to draw a small square(handles) on the edge of a circle at each quadrant?

    This might help you too. Sorry for the crappy graphics.

    1911

    Actually, looking at this, it may be easier to find your x (distance out from origin) first, then use x sin(some angle) = y, which...
  12. Re: How to draw a small square(handles) on the edge of a circle at each quadrant?

    I would start by finding the x,y coord of the center of the circle, then imagine drawing a Cartesian coordinate system from there, +/- x and +/- y directions. Then, just figure out how far you need...
  13. Re: problem accessing variables in multiple classes

    Yeah, sorry for wasting some space. It's just an excuse, but I was on my way to another class as I rush-posted this problem. I will be more careful with test programs in the future. My biggest...
  14. Re: problem accessing variables in multiple classes

    Thank you for running the code. I was trying to frame my actual problem with this simplified example, and it turns out this example works. Problem solved in the "what's wrong with my code thread." ...
  15. Re: one variable in a third class is being reported as holding different values when references from objects in two different classes! please help!

    Two! And is that the problem? So I should pass the FuelGauge object to the odometer class from main... THANK YOU!!!

    --- Update ---




    That was it! You're a lifesaver! Thank you!
  16. one variable in a third class is being reported as holding different values when references from objects in two different classes! please help!

    This program is supposed to simulate a fuel gauge and odometer. I am having trouble because two class objects in two different classes, referencing the same variable in a third class, are reporting...
  17. problem accessing variables in multiple classes

    My problem:


    I have two .java files. One with the main method, and one as a separate class, which I create an instance of in my main method.
    When I use the instance of the class to increment...
  18. Replies
    17
    Views
    309

    Re: Help with simple math game coding

    @JMD

    Hey, I know what you mean; I use this all the time to demand the user enter an integer:




    Scanner input = new Scanner(System.in);

    System.out.println("Enter an integer: ");
  19. Replies
    54
    Views
    979

    [SOLVED] Re: Access Denied!

    Norm is like Google. Endless amounts of information. I'm amazed.
  20. Replies
    1
    Views
    95

    Re: Code problems

    I haven't examined your whole program, but an easy way to get the menu to repeat itself is to wrap the whole thing in a while loop, with a boolean condition, like:




    boolean done = false;
    ...
  21. Re: Help fixing my Java program! Reading files

    Post retracted. Good advice already given..
  22. Replies
    17
    Views
    309

    Re: Help with simple math game coding

    Are you using .floor and .ceil to lower/raise each random double then type-casting to int, to ensure two different results? If so, creative. Well done!
  23. Replies
    1
    Views
    472

    Re: Best laptops for java development

    Future-proof yourself and buy something that will last a couple of years. I would get an ultra-book with a capacitive touch display and 1080p resolution, running Windows 8. Also, I would get at...
  24. Replies
    1
    Views
    155

    Re: any book for java 2d games?

    I don't know if any of this will be useful to you, but:

    Java game tutorial

    Java 2D games tutorial

    Space Invaders 101 - An Accelerated Java 2D Tutorial
  25. Replies
    17
    Views
    309

    Re: Help with simple math game coding

    Use a loop to keep generating random ints until randomOne != randomTwo.



    By defining it outside the method. Literally place the statement creating the random object outside of the method, but...
Results 1 to 25 of 89
Page 1 of 4 1 2 3 4