This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
String input = "1 fish 2 fish red fish blue fish"; Scanner s = new Scanner(input); s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)"); MatchResult result = s.match(); for (int i=1; i<=result.groupCount(); i++) System.out.println(result.group(i); s.close();
What has confused me is that is the method summary on the same page, it states that findInLine returns a String value. The above example clearly does not return a value into a String. My question is as follows:
Is it the case that because it returns a value that is sub-classed off Object that it imlicitly performs a "new String()" and creates an anonamous instance of the object (in this case a String)? Or is there something else happening here?
If at first you don't succeed, try, try again. If you don't try you have failed.