Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25
  1. #21
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    ok, I looked it up. here's what the textbook has to say about array initializations:

    When an array is created, its elements are assigned the default value of:
    0 for the numeric primitive data types,
    '\u0000' for char types,
    false for boolean types.

  2. #22
    leiferouis is offline Member
    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    0

    Default

    One more question thats completely unrelated but part of the same assignment.
    Java Code:
    char1 = (String.charAt[1]).toUpperCase();
    char1 is a char variable, string is a string variable with a name in it.
    This doesn't work, its giving me an error saying that char is not a reference type.

  3. #23
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    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.

  4. #24
    leiferouis is offline Member
    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    0

    Default

    What would be a good way of capitalizing without any data type confusion?

  5. #25
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    char1 = (s.toUpperCase()).charAt(1);
    well, there are better ways. best to read the java doc.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Drawing a map
    By Karp in forum AWT / Swing
    Replies: 4
    Last Post: 11-07-2008, 01:26 PM
  2. Triangles
    By CodeDog in forum New To Java
    Replies: 9
    Last Post: 10-14-2008, 10:18 PM
  3. Demonstration of drawing an Arc in SWT
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 06-28-2008, 10:24 PM
  4. Help with 2-D Drawing
    By Deathmonger in forum New To Java
    Replies: 4
    Last Post: 06-18-2008, 03:23 AM
  5. asterisks triangles
    By Dan121 in forum New To Java
    Replies: 1
    Last Post: 01-12-2008, 08:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •