Skip to content

Instantly share code, notes, and snippets.

@paulolorenzobasilio
Created August 6, 2019 04:20
Show Gist options
  • Save paulolorenzobasilio/a917444bf3617c588bb5a5419500a96c to your computer and use it in GitHub Desktop.
Save paulolorenzobasilio/a917444bf3617c588bb5a5419500a96c to your computer and use it in GitHub Desktop.
Example of output argument in Java. See this for more details https://www.quora.com/What-is-an-example-of-output-arguments-in-Java
public class OutputArgument
{
public static void main (String[]args)
{
int[] source = { 1, 2, 3, 4, 5, 6 };
int[] destination = new int[6];
copyFromSourceToDestination (source, destination);
for (int i = 0; i < source.length; i++) {
System.out.println (destination[i]);
}
//Outputs 1 2 3 4 5
}
public static void copyFromSourceToDestination (int[]source, int[]destination) {
for (int i = 0; i < source.length; i++) {
destination[i] = source[i];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment