Results 1 to 2 of 2

Thread: String passing

  1. #1
    MIA6 is offline Member
    Join Date
    Oct 2009
    Posts
    17
    Rep Power
    0

    Exclamation String passing

    What should I be aware of when it comes to String passing? I think when I was programming, I passed primitive values most of the time, and my teacher said to be careful of String passing, so I don't know what I should pay attention to?
    Thanks.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    Strings in Sun's Tutorial might be worth reading.

    I'm not aware of anything special to be aware of with regard to passing a reference to a string to a method. (or of return values). But remember that you use equals() to compare strings to see if they consist of the same characters in the same order. (== compares the reference values). And that strings are immutable - they will forever consist of the same characters they started with. So "str.toUpperCase()" won't convert str, instead you have to form a new string and assign it back to the variable with "str=str.toUpperCase()".

Similar Threads

  1. Passing a value..
    By Lagarto in forum New To Java
    Replies: 3
    Last Post: 01-23-2011, 06:58 PM
  2. passing something
    By dinosoep in forum Threads and Synchronization
    Replies: 2
    Last Post: 12-05-2009, 10:26 AM
  3. Replies: 7
    Last Post: 11-03-2009, 03:18 AM
  4. how use string array while passing to a function
    By sks9s9 in forum New To Java
    Replies: 2
    Last Post: 02-03-2009, 01:44 PM
  5. Replies: 5
    Last Post: 01-11-2009, 11:12 AM

Posting Permissions

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