Anonymous Array in Java Last Updated : 22 Apr, 2022 Suggest changes Share Like Article Like Report An array in Java without any name is known as an anonymous array. It is an array just for creating and using instantly. Using an anonymous array, we can pass an array with user values without the referenced variable. Properties of Anonymous Arrays: We can create an array without a name. Such types of nameless arrays are called anonymous arrays.The main purpose of an anonymous array is just for instant use (just for one-time usage).An anonymous array is passed as an argument of a method. Note: For Anonymous array creation, do not mention size in []. The number of values passing inside {} will become the size. Syntax: new <data type>[]{<list of values with comma separator>}; Examples: // anonymous int array new int[] { 1, 2, 3, 4}; // anonymous char array new char[] {'x', 'y', 'z'}; // anonymous String array new String[] {"Geeks", "for", "Geeks"}; // anonymous multidimensional array new int[][] { {10, 20}, {30, 40, 50} };Implementation: Java // Java program to illustrate the // concept of anonymous array class Test { public static void main(String[] args) { // anonymous array sum(new int[]{ 1, 2, 3 }); } public static void sum(int[] a) { int total = 0; // using for-each loop for (int i : a) total = total + i; System.out.println("The sum is: " + total); } } OutputThe sum is: 6 Explanation: In the above example, just to call the sum method, we required an array, but after implementing the sum method, we are not using the array anymore. Hence for this one-time requirement anonymous array is the best choice. Based on our requirement, we can later give the name to the anonymous array, and then it will no longer be anonymous. Advertise with us Next Article Anonymous Array in Java B Bishal Kumar Dubey Similar Reads Anonymous Inner Class in Java Nested Classes in Java is prerequisite required before adhering forward to grasp about anonymous Inner class. It is an inner class without a name and for which only a single object is created. An anonymous inner class can be useful when making an instance of an object with certain "extras" such as o 7 min read Anonymous Object in Java In Java, an anonymous object is an object that is created without giving it a name. Anonymous objects are often used to create objects on the fly and pass them as arguments to methods. Here is an example of how to create and use an anonymous object in Java. Example:Java import java.io.*; class Perso 2 min read What is Java Anonymous Proxy? Java Anonymous Proxy or JAP is a technique that allows users to use the internet secretly. In more technical terms, this means that without revealing the IP address, one can use the internet in an anonymous condition. There are a series of routers through which traffic is routed, this is known as pr 5 min read Interesting Facts About Java Java: A general-purpose, high-level programming language. It is developed by Sun Microsystems. It was developed by a mini team of engineers which is known as the Green Team. They initiated this language in 1991. Here are some interesting facts about Java: The initial name of java was "Oak". It was c 2 min read Coding Guidelines in Java Java is one of the most popular and widely used programming languages and platforms. A platform is an environment that helps to develop and run programs written in any programming language. Java is fast, reliable, and secure. From desktop to web applications, scientific supercomputers to gaming cons 7 min read Article Tags : Misc Java Competitive Programming DSA Java-Arrays Java-Array-Programs +2 More Practice Tags : JavaMisc Like