xFactorSchool.com
Python
JavaScript
How to Do Examples
C Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Compilers
C Compiler
C++ Compiler
C# Compiler
Java Compiler
Python Compiler
HTML Code Editor
CSS Code Editor
JavaScript Compiler
JavaScript Code Editor
Practice how to create an array in Java
Java Online Editor
Execute Code
More Java Sample Codes
public class ExampleApp { public static void main(String[] args) { // Creating a string array in one line using array declaration syntax String[] fruits = { "Apple", "Banana", "Cherry", "Orange", "Watermelon" }; // array of strings // Accessing an array element System.out.println(fruits[2]); // Output: Cherry // Creating an integer array in one line using array declaration syntax int[] numbers = { 1, 2, 3, 4, 5 }; // array of integers // Accessing an array element System.out.println(numbers[2]); // Output: 3 } }