The method that returns nothing uses the keyword 'void' in the method declaration else it needs a return type for this purpose. 2. While returning a reference to an array from a method, you should keep in mind that: The data type that returns value should be specified as the array of the appropriate data type. Array elements are converted to strings using the String.valueOf() method, like this: How do you separate zeros from non-zeros in an integer array using Java? The second programs takes the value of n (number of elements) and the numbers provided by user and finds the average of them using array. i dont know jack shit about code, how do i run a .jar file? 1) I have declared an array called student [] in main program 2)I initialised the array inside the function void modifyRef().I can print the values inside the function.I need to get the values returned in the main function. Reserve String without reverse() function, How to Convert Char Array to String in Java, How to Run Java Program in CMD Using Notepad, How to Take Multiple String Input in Java Using Scanner, How to Remove Last Character from String in Java, Java Program to Find Sum of Natural Numbers, Java Program to Display Alternate Prime Numbers, Java Program to Find Square Root of a Number Without sqrt Method, Java Program to Swap Two Numbers Using Bitwise Operator, Java Program to Break Integer into Digits, Java Program to Find Largest of Three Numbers, Java Program to Calculate Area and Circumference of Circle, Java Program to Check if a Number is Positive or Negative, Java Program to Find Smallest of Three Numbers Using Ternary Operator, Java Program to Check if a Given Number is Perfect Square, Java Program to Display Even Numbers From 1 to 100, Java Program to Display Odd Numbers From 1 to 100, Java Program to Read Number from Standard Input, Which Package is Imported by Default in Java, Could Not Find or Load Main Class in Java, How to Convert String to JSON Object in Java, How to Get Value from JSON Object in Java Example, How to Split a String in Java with Delimiter, Why non-static variable cannot be referenced from a static context in Java, Java Developer Roles and Responsibilities, How to avoid null pointer exception in Java, Java constructor returns a value, but what. In C you cannot return an array directly from a function. (ii) Consider a function reverse which takes the parameters-the array (say arr) and the size of the array (say n). How do you find the number of dimensions of an array in C#? But that does not impose a restriction on C language. In general, arrays are the containers that store multiple variables of the same datatype. 1. It returns the String representation of an array. It does not return anything. The elements of an array are stored in a contiguous memory location. import java.util.Arrays; import java.util.Scanner; public class ReturningAnArray { public int[] createArray() { Scanner sc = new Scanner(; System.out.println("Enter the size of the array that is to be created:: "); int size = sc.nextInt(); int[] myArray = new int[size]; System.out.println("Enter the elements of the array ::"); for(int i=0; i

how to print a returned array in java 2021