Skip to content

Latest commit

 

History

History

02_Arrays_Strings

This section focuses on Arrays and Strings, two key components of Java. You'll learn how to store, manipulate, and search through data in arrays and perform various string operations.

Topics Covered:

  1. Arrays - Declaration, initialization, sorting, and searching.
  2. Strings - String manipulation, functions like length(), charAt(), and equals().

Example Programs:

  • ArraysDemo.java - Demonstrates how to initialize and print elements of an array.
  • Sorting.java - Sort an array in ascending and descending order.
  • BinarySearch.java - Perform binary search on an array of integers.
  • LinearSearch.java - Perform linear search on an array of integers.
  • MatrixOperations.java - Perform addition and multiplication on matrices.
  • SmallestElement.java - Find the smallest element in an array.
  • StringDemo.java - Show usage of basic String methods.

Exercises:

  1. Write a program to initialize and print elements of an array.
  2. Write a program to perform a linear search on an array.
  3. Write a program to demonstrate any 10 String class functions.
  4. Write a program to sort an array of integers in ascending and descending order.
  5. Write a program to perform addition and multiplication on matrices.
  6. Write a program to find the smallest element in an array.

Once you've understood arrays and strings, proceed to Classes & Objects.


Files

  • ArraysDemo.java: Demonstrates basic array operations.
  • BinarySearch.java: Implements binary search algorithm.
  • LinearSearch.java: Implements linear search algorithm.
  • MatrixOperations.java: Perform operations on matrices.
  • SmallestElement.java: Find the smallest element in an array.
  • Sorting.java: Demonstrates sorting algorithms.