Results 1 to 3 of 3
- 10-19-2012, 09:42 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 28
- Rep Power
- 0
String - substring and toUpperCase in same println.
I'm trying to do this selfcheck from my java learning book:
Consider the following String:
String quote = "Four score and seven years ago";
What expression produces the new String "SCORE"? What expression produces "four years"?
This is my failed attempt:
I guess I'm supposed to do each line, with only use of a single println statement. At least that's what I'm trying to, but failing at.Java Code:public class SelfCheck_3_15 { public static void main(String[] args) { String quote = "Four score and seven years ago"; System.out.println(quote.substring(5, 10) + quote.toUpperCase()); System.out.println(quote.substring(0, 4) + " " + quote.substring(21, 26)); } }
Well I can see why it's not working, but what should I change to make it work?
- 10-19-2012, 10:01 PM #2
Member
- Join Date
- Sep 2012
- Posts
- 34
- Rep Power
- 0
Re: String - substring and toUpperCase in same println.
you should do something like quote.substring(5,10).toUpperCase()
- 10-19-2012, 10:09 PM #3
Member
- Join Date
- Oct 2012
- Posts
- 28
- Rep Power
- 0
Similar Threads
-
Searching for a substring within a String
By Tryx in forum New To JavaReplies: 7Last Post: 07-16-2012, 08:12 PM -
A string and substring problem
By calnastic in forum New To JavaReplies: 4Last Post: 07-18-2011, 09:02 PM -
How do I remove a substring from a string?
By Unnel in forum New To JavaReplies: 16Last Post: 07-11-2011, 11:56 AM -
Search Substring in String Help Please
By Kestrel01 in forum New To JavaReplies: 3Last Post: 10-26-2010, 06:48 PM -
String substring function
By ravian in forum New To JavaReplies: 6Last Post: 01-02-2008, 07:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks