Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created September 15, 2008 17:39
Show Gist options
  • Save ELLIOTTCABLE/10899 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/10899 to your computer and use it in GitHub Desktop.
[Mon Sep 15 - 09:36:15] [elliottcable @ Geoffrey] [~/Code/school/]
-- javac Exercises.java && java Exercises
Exercises.java:11: cannot find symbol
symbol : method getCharAt(int)
location: class java.lang.String
char last_character = input.getCharAt(last_char_index);
^
1 error
[Mon Sep 15 - 09:42:34] [elliottcable @ Geoffrey] [~/Code/school/]
--
import java.util.Scanner;
public class Exercises {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Hello! Say something...");
String input = keyboard.next();
int last_char_index = input.length() - 1;
char last_character = input.getCharAt(last_char_index);
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment