View Single Post
  #4 (permalink)  
Old 11-12-2007, 10:19 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
Exercise8_18.java:11: cannot find symbol symbol : variable str
Java cannot find a declaration for the variable "str" - it has not been declared.
You did however declare a string "s" and you saved the user input in it.
Code:
public class Exercise8_18 { /**Main method*/ public static void main(String[] args) { // Receive text entered from the dialog box // Save it in local variable "s". String s = JOptionPane.showInputDialog("Enter a sentence " + "using punctuation:"); String delims = "[\\s\\p{Punct}]+"; // Split the String "s": String[] tokens = s.split(delims); System.out.println("The extracted words are: " + java.util.Arrays.toString(tokens));
Reply With Quote