Skip to content

Instantly share code, notes, and snippets.

@mrmemmo
Created November 10, 2020 13:27
Show Gist options
  • Save mrmemmo/af83cac92d2217c830eb9aa8bbdde981 to your computer and use it in GitHub Desktop.
Save mrmemmo/af83cac92d2217c830eb9aa8bbdde981 to your computer and use it in GitHub Desktop.
public class PassingParameters
{
static int xs = 5;
public static void main(String[] args)
{
int y = 10;
sendY(y);
System.out.println("y " + y);
int x = 15;
changeX(x);
String s = "Hello";
changeS(s);
int[] arr = {1,2,3,4};
for (int a:arr){
System.out.print(a + " ");
}
changeArr(arr);
System.out.println("");
for (int a:arr){
System.out.print(a + " ");
}
}
public static void sendY(int y)
{
y = y + 10;
}
public static void changeX(int x)
{
xs = x + 10;
x = xs;
System.out.println("x " + x);
}
public static void changeS(String s){
s = "Good Bye";
}
public static void changeArr(int[] arr){
arr[1] = 6;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment