Hi,
This should be very simple, but I am a beginner.
1. An object is passed to a method by reference?
2. A string is an object?
3. Hence, a string is passed to a meshod by reference?
public class Try
{
public static void main(String[] args)
{
String s="222222";
System.out.println(s);
System.out.println(test(s));
System.out.println(s);
}
static String test(String s)
{
s += "11111111";
return s;
}
}
This should be very simple, but I am a beginner.
1. An object is passed to a method by reference?
2. A string is an object?
3. Hence, a string is passed to a meshod by reference?
public class Try
{
public static void main(String[] args)
{
String s="222222";
System.out.println(s);
System.out.println(test(s));
System.out.println(s);
}
static String test(String s)
{
s += "11111111";
return s;
}
}