KEMBAR78
? Page 5 | PDF
0% found this document useful (0 votes)
16 views1 page

? Page 5

The document provides an overview of arrays and methods in Java, including single and multidimensional arrays with examples. It also explains how to define and call methods, as well as the concept of method overloading. Code snippets illustrate these concepts clearly.

Uploaded by

online school
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

? Page 5

The document provides an overview of arrays and methods in Java, including single and multidimensional arrays with examples. It also explains how to define and call methods, as well as the concept of method overloading. Code snippets illustrate these concepts clearly.

Uploaded by

online school
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

📄 Page 5: Arrays and Methods

Arrays

 Single Dimensional Array

java
CopyEdit
int[] numbers = {1, 2, 3, 4};
System.out.println(numbers[0]); // Output: 1

 Multidimensional Array

java
CopyEdit
int[][] matrix = {
{1, 2},
{3, 4}
};
System.out.println(matrix[1][1]); // Output: 4

Methods (Functions)

 Define a Method

java
CopyEdit
public static int add(int a, int b) {
return a + b;
}

 Calling a Method

java
CopyEdit
int result = add(5, 10);
System.out.println(result);

Method Overloading
java
CopyEdit
int sum(int a, int b) { return a + b; }
double sum(double a, double b) { return a + b; }

You might also like