Master Java Arrays in 15 Minutes: Linear Search & Sum (BlueJ Tutorial)
Автор: ICSE COMPUTER SAATHI
Загружено: 2026-01-13
Просмотров: 13
In this video, we cover two fundamental Java Array programs for ICSE Class 10 Computer Applications:
1. How to input numbers into an array and calculate their SUM.
2. How to perform LINEAR SEARCH to find a specific number.
These are potential 15-mark questions for Section B of your Board Exam. I explain the logic, the code in BlueJ, and common mistakes to avoid.
-------------------------------------------------------
📝 EXAM NOTE (For 15/15 Marks):
In the video, I focused on the logic explanation.
In your Board Exam, you MUST add "Comments" and the "Variable Description Table" (VDT) to get full marks.
Below is the 100% Correct Code + VDT for your notebook.
-------------------------------------------------------
✅ PROGRAM 1: INPUT AND SUM OF ARRAY ELEMENTS
-------------------------------------------------------
import java.util.Scanner;
public class ArraySum {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
// Declaration of Array
int arr[] = new int[5];
int sum = 0; // Accumulator initialized to 0
// Input Phase: Accepting 5 numbers
System.out.println("Enter 5 numbers:");
// Note: We use '!=' instead of less-than symbol for YouTube formatting
for(int i = 0; i != arr.length; i++) {
arr[i] = sc.nextInt();
}
// Calculation Phase: Adding elements to sum
for(int i = 0; i != arr.length; i++) {
sum = sum + arr[i];
}
System.out.println("Total Sum: " + sum);
}
}
👉 Variable Description Table (Program 1)
| Variable Name | Data Type | Description |
| :--- | :--- | :--- |
| arr | int[] | Integer array to store 5 numbers |
| i | int | Loop control variable |
| sum | int | Stores the total sum of array elements |
| sc | Scanner | Object to invoke Scanner class methods |
-------------------------------------------------------
✅ PROGRAM 2: LINEAR SEARCH IN ARRAY
-------------------------------------------------------
import java.util.Scanner;
public class LinearSearch {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int arr[] = new int[10];
// Input Phase: Accepting 10 numbers from user
System.out.println("Enter 10 numbers:");
for(int i = 0; i != 10; i++) {
arr[i] = sc.nextInt();
}
// Search Phase: Input the target number
System.out.print("Enter number to search: ");
int target = sc.nextInt();
int foundIndex = -1; // Flag variable (assumed not found)
// Logic: Linear Search Algorithm
for(int i = 0; i != 10; i++) {
if(arr[i] == target) {
foundIndex = i; // Store index if match found
break; // Stop loop immediately to save time
}
}
// Output Phase: Displaying the result
if(foundIndex != -1) {
System.out.println("Number found at Index: " + foundIndex);
} else {
System.out.println("Number not found");
}
}
}
👉 Variable Description Table (Program 2)
| Variable Name | Data Type | Description |
| :--- | :--- | :--- |
| arr | int[] | Integer array to store 10 numbers |
| i | int | Loop control variable |
| target | int | The number to be searched in the array |
| foundIndex | int | Stores the index of the found element |
| sc | Scanner | Object to invoke Scanner class methods |
-------------------------------------------------------
#ICSEClass10 #JavaProgramming #LinearSearch #BlueJ #ComputerApplications #icse2026
-------------------------------------------------------
🎵 MUSIC CREDITS
-------------------------------------------------------
Track: Endless And Vibrations
Artist: Davidlaski Couture
Album: Hell of the Morning After
Track: Hell of the Morning After
Artist: Davidlaski Couture
Album: Hell of the Morning After
-------------------------------------------------------
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: