Hints for lab 3 about working with strings and characters

10 Jun 2024 - 18:40 | Version 1 |
  1. To get a character, read in a string and then use the charAt() function. See the class example for the exact syntax
  2. It is best in this lab to do keyboard.nextLine() after any keyboard.nextDouble() if one is getting a string after a double. This is important to "eat" the end of line character after the double before getting the string on the next line of input. Example:
    number = keyboard.nextDouble();
    keyboard.nextLine();
    …
    str = keyboard.nextLine();
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This website is using cookies. More info. That's Fine