Results 21 to 25 of 25
Thread: Drawing out triangles
- 01-15-2009, 05:19 PM #21
- 01-16-2009, 03:26 AM #22
Member
- Join Date
- Jan 2009
- Posts
- 31
- Rep Power
- 0
One more question thats completely unrelated but part of the same assignment.
char1 is a char variable, string is a string variable with a name in it.Java Code:char1 = (String.charAt[1]).toUpperCase();
This doesn't work, its giving me an error saying that char is not a reference type.
- 01-16-2009, 04:13 AM #23
two things about charAt.
1) its a method, so you can't use []. you need ()
2) its non-static, so you can't use "String". but a string object.
For beginner, its best not to chain them because its easy to get confused. The return type for the method charAt() is a char. So what you are trying to do is:
charVar.toUpperCase();
Which is impossible, because...
hint: primary data types.
- 01-16-2009, 04:14 PM #24
Member
- Join Date
- Jan 2009
- Posts
- 31
- Rep Power
- 0
What would be a good way of capitalizing without any data type confusion?
- 01-16-2009, 08:18 PM #25
char1 = (s.toUpperCase()).charAt(1);
well, there are better ways. best to read the java doc.USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
Similar Threads
-
Drawing a map
By Karp in forum AWT / SwingReplies: 4Last Post: 11-07-2008, 12:26 PM -
Triangles
By CodeDog in forum New To JavaReplies: 9Last Post: 10-14-2008, 09:18 PM -
Demonstration of drawing an Arc in SWT
By Java Tip in forum SWTReplies: 0Last Post: 06-28-2008, 09:24 PM -
Help with 2-D Drawing
By Deathmonger in forum New To JavaReplies: 4Last Post: 06-18-2008, 02:23 AM -
asterisks triangles
By Dan121 in forum New To JavaReplies: 1Last Post: 01-12-2008, 07:42 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks