-1
package com.mkyong.test;

public class Main {

    public static void main(String[] args) {
        String something = "";
        callSomething(something);

        System.out.println(something);
    }

    private static String callSomething(String something) {
        something = "Hello Wrold !";
        return something;
    }
}
Konstantin Yovkov
  • 62,134
  • 8
  • 100
  • 147
Azhar Mohamed
  • 365
  • 3
  • 11

1 Answers1

0

No, in the method, you are changing the reference of the local variable something.

Change your method call to:

something = callSomething(something);
Stultuske
  • 9,296
  • 1
  • 25
  • 37