Tuesday, 22 April 2025

Introduction to Java Arrays

 

In Java, an array lets you store multiple values in a single variable. Super useful when you’re working with a list of items!

//Structure of arrays in java

int[] numbers = {10, 20, 30, 40};

//Accessing Elements

System.out.println(numbers[0]); // 10

System.out.println(numbers[2]); // 30


๐Ÿ’ฅ Array Properties

  • Fixed size (you can’t change its length)

  • Index starts at 0

  • numbers.length gives you the number of elements


๐Ÿงช Challenge

Create an array of your 5 favorite numbers and print them all using a loop.



No comments:

Post a Comment

๐Ÿ‘จ‍๐Ÿ’ป How I Started Learning Java at 15 (and You Can Too)

  When I first heard of Java, I thought it was just something to do with Minecraft mods or Android apps. I didn’t realize it would become my...