DEV Community

Cover image for One Commit at a Time Series - 4
Annapoorani Kadhiravan
Annapoorani Kadhiravan

Posted on Edited on

One Commit at a Time Series - 4

LINUX

man - is used to display command manuals
grep - is used to search text patters [case sensitive]
echo - is used to display text in terminal
wget - is used to download files from internet using URL
whoami - is used to display the current user
sort - is used to sort file contents
cal - is used to display the calendar
whereis - is used to locate command files
df - is used to display disk space usage
wc - is used to display number of lines, words and bytes in the file


JAVA

# Check if Int Array contains a given value

class Main {
  public static void main(String[] args) {

    int[] num = {1, 2, 3, 4, 5};
    int toFind = 3;
    boolean found = false;

    for (int n : num) {
      if (n == toFind) {
        found = true;
        break;
      }
    }

    if(found)
      System.out.println(toFind + " is found.");
    else
      System.out.println(toFind + " is not found.");
  }
}

Enter fullscreen mode Exit fullscreen mode

Explanations

  • class Main: Declares a public class named Main, which serves as the container for the Java program.
  • public static void main(String[] args): The main entry point of any Java application where execution begins.
  • int[] num = {1, 2, 3, 4, 5};: Declares and initializes an integer array containing elements 1 through 5.
  • int toFind = 3;: Defines the specific integer value we want to check for in the array.
  • boolean found = false;: Initializes a boolean flag to track whether the target value has been located.
  • for (int n : num): Iterates sequentially through each element in the array.
  • if (n == toFind): Checks if the current array element matches the target value.
  • found = true;: Updates the flag to true since the value has been matched.
  • break;: Exits the loop immediately once the value is found to save processing time.
  • if(found): Evaluates whether the flag remains true after the loop completes.
  • System.out.println(toFind + " is found.");: Prints a confirmation message if the value exists in the array.
  • System.out.println(toFind + " is not found.");: Prints a message if the loop completed without finding the value.

SQL

DML – Data Manipulation Language
Used to manipulate data stored in tables.

INSERT → Add new records.

UPDATE → Modify existing records.

DELETE → Remove records.

MERGE → Combine data from multiple sources.

Example:

INSERT INTO Students (StudentID, Name, Age)
VALUES (1, 'Annapoorani', 22);
Enter fullscreen mode Exit fullscreen mode

References :

https://www.geeksforgeeks.org/linux-unix/basic-linux-commands/

Top comments (0)