Advertisement

06.18.2007 at 02:01PM PDT, ID: 22641728
[x]
Attachment Details

Problem with Java static method variable return

Asked by anneaquilino in Java Server Pages (JSP), New to Java Programming

Tags: java, static, method

Hi,

I am fairly new to java and oo, and this is driving me batty!  I have a class with a static method that receives a String, performs some formatting on it and returns the new string, but it returns the passed parameter, not the new string.

Class:
public class StyleUtils {
    public static String urlEncode(String myString) {
          String s ="new string";        
           return s;
    }
}

Call:
String testString = StyleUtils.urlEncode("mytest");

The value ending up in testString is "mytest", but it should be "new string"...what am I doing wrong????

Thanks for your help!  Anne
Start Free Trial
 
Loading Advertisement...
 
[+][-]06.18.2007 at 02:25PM PDT, ID: 19310849

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Server Pages (JSP), New to Java Programming
Tags: java, static, method
Sign Up Now!
Solution Provided By: objects
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.19.2007 at 03:46AM PDT, ID: 19314605

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.19.2007 at 03:47AM PDT, ID: 19314608

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.19.2007 at 04:49AM PDT, ID: 19314898

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.19.2007 at 06:28AM PDT, ID: 19315594

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32