<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Neelakandan R</title>
    <description>The latest articles on Forem by Neelakandan R (@neelakandan_ravi).</description>
    <link>https://forem.com/neelakandan_ravi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2589617%2F7dc511f3-6b40-4e40-8858-4f998cd51c96.jpg</url>
      <title>Forem: Neelakandan R</title>
      <link>https://forem.com/neelakandan_ravi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/neelakandan_ravi"/>
    <language>en</language>
    <item>
      <title>Java Challenge: Can You Explain This Bitwise + Recursive Arithmetic Program?</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Tue, 05 Aug 2025 05:48:01 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/java-challenge-can-you-explain-this-bitwise-recursive-arithmetic-program-55n1</link>
      <guid>https://forem.com/neelakandan_ravi/java-challenge-can-you-explain-this-bitwise-recursive-arithmetic-program-55n1</guid>
      <description>&lt;p&gt;Given the following Java class containing four custom methods — findsum(), findsub(), multi(), and divide() — can you explain how each method works internally without using standard arithmetic operators?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Afternoon;

public class oper {

    public static void main(String[] args) {
        findsum(4, 2);
        findsub(10, 20);
        System.out.println("multi :"+multi(5, 7));
        divide(100, 8);

    }

    private static void divide(int a, int b) {
        int bal = 0;
        while (a &amp;gt;= b) {
            a = a - b;
            bal++;
        }
        System.out.println("quotient :" + bal + " " + "reminder :" + a);
    }

    private static int multi(int i, int j) {
        if (j == 0) {
            return 0;
        }
        return i + multi(i, j - 1);

    }

    private static void findsub(int i, int j) {
        int total = i + (~j + 1);
        System.out.println("sub"+total);

    }

    private static void findsum(int a, int b) {
        while (b != 0) {
            int carry = a &amp;amp; b;// 0100 &amp;amp; 0010=0000
            a = a ^ b;// 0100 &amp;amp; 0010=0110
            b = carry &amp;lt;&amp;lt; 1;// 0000
        }
        System.out.println("add :"+a);
    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
add :6&lt;br&gt;
sub-10&lt;br&gt;
multi :35&lt;br&gt;
quotient :12 reminder :4&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>fullstack</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Happy Numbers,Trapping of Rainwater</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Thu, 31 Jul 2025 05:23:27 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/happy-numberstrappingofrainwater-4623</link>
      <guid>https://forem.com/neelakandan_ravi/happy-numberstrappingofrainwater-4623</guid>
      <description>&lt;p&gt;&lt;u&gt;&lt;strong&gt;While scrolling through LinkedIn, I came across a question about Happy Numbers. I solved it, and it was quite interesting.&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;what is happy number 😜 :&lt;br&gt;
Examples : &lt;br&gt;
Input: n = 19&lt;br&gt;
Output: True&lt;br&gt;
19 is Happy Number,&lt;br&gt;
1^2 + 9^2 = 82&lt;br&gt;
8^2 + 2^2 = 68&lt;br&gt;
6^2 + 8^2 = 100&lt;br&gt;
1^2 + 0^2 + 0^2 = 1&lt;br&gt;
As we reached to 1, 19 is a Happy Number.&lt;br&gt;
Input: n = 20&lt;br&gt;
Output: False&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Interview_practice;

import java.util.HashSet;
import java.util.Scanner;

public class HappyNumber {
 public static void main(String[] args) {
 System.out.println("Enter Number To find happynumber :");
 Scanner sc = new Scanner(System.in);
 int num = sc.nextInt();
 if (happynum(num) == true) {
 System.out.println("Happy number");
 } else {
 System.out.println("Not Happy number");
 }
 sc.close();
 }

 public static boolean happynum(int num) {

 HashSet&amp;lt;Integer&amp;gt; seen = new HashSet&amp;lt;Integer&amp;gt;();// store and find repeated num
 while (num != 1 &amp;amp;&amp;amp; !seen.contains(num)) {
 seen.add(num);
 num = findhappy(num);
 }
 if (num == 1) {
 return true;
 } else {
 return false;
 }

 }

 public static int findhappy(int num) {
 int total = 0;
 while (num &amp;gt; 0) {
 int n = num % 10;
 total += n * n;
 num = num / 10;
 }
 return total;
 }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Enter Number To find happynumber :&lt;br&gt;
19&lt;br&gt;
Happy number 😜 &lt;br&gt;
Enter Number To find happynumber :&lt;br&gt;
78&lt;br&gt;
Not Happy number 🥲 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Afternoon;

public class Trapping_of_Rainwater {
    public static void main(String[] args) {
        int[] heigth = { 0, 4, 5, 1};
        int[] left = new int[heigth.length];
        int[] rigth = new int[heigth.length];
        int n = findtrapWater(heigth, left, rigth);
        System.out.println("Trapping_of_Rainwater :" + n + " units.");
    }

    private static int findtrapWater(int[] heigth, int[] left, int[] rigth) {
        int max = 0;
        for (int i = 0; i &amp;lt; heigth.length; i++) {
            if (heigth[i] &amp;gt;= max) {
                max = heigth[i];

            }
            left[i] = max;//0 4 5 5
        }

        max = 0;
        for (int i = heigth.length - 1; i &amp;gt;= 0; i--) {
            if (heigth[i] &amp;gt;= max) {
                max = heigth[i];
            }
            rigth[i] = max;//5 5 5 1

        }

        int total = 0;
        for (int i = 0; i &amp;lt; heigth.length; i++) {
            int minHeigth = 0;
            if (left[i] &amp;lt; rigth[i]) {
                minHeigth = left[i];
            } else {
                minHeigth = rigth[i];
            }
            //heigth[i] 0 4 5 1
            total += minHeigth - heigth[i];//0-0+4-4+5-5+1-1
        }
        return total;

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Trapping_of_Rainwater :0 units.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>payilagam</category>
      <category>interview</category>
    </item>
    <item>
      <title>simple ATM Project in Java-covering full CRUD (without DB, using console + Java basics).</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Sun, 27 Jul 2025 05:05:19 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/simple-atm-project-in-java-covering-full-crud-without-db-using-console-java-basics-1mol</link>
      <guid>https://forem.com/neelakandan_ravi/simple-atm-project-in-java-covering-full-crud-without-db-using-console-java-basics-1mol</guid>
      <description>&lt;p&gt;Here's a simple ATM Project in Java that includes Account Creation, View, Deposit, Withdraw, and Deletion – covering full CRUD (without DB, using console + Java basics).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;What it does:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a new account with an account number, name, and initial balance&lt;/p&gt;

&lt;p&gt;View account details&lt;/p&gt;

&lt;p&gt;Deposit money into an account&lt;/p&gt;

&lt;p&gt;Withdraw money from an account (with balance checks)&lt;/p&gt;

&lt;p&gt;Delete an account&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Interview_practice;

public class Account {
int accNo;
String name;
double balance;
public Account(int accNo,String name,double balance)
{
    this.accNo=accNo;
    this.name=name;
    this.balance=balance;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Interview_practice;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class ATM {
    static Scanner sc = new Scanner(System.in);
    static Map&amp;lt;Integer, Account&amp;gt; accounts = new HashMap&amp;lt;&amp;gt;();

    public static void main(String[] args) {
        while (true) {
            System.out.println("\n1.create\n2.view\n3.Deposit\n4.Withdraw\n5.Delete\n6.Exit");
            int ch = sc.nextInt();
            switch (ch) {
            case 1:
                createAccount();
                break;
            case 2:
                viewAccount();
                break;
            case 3:
                depositeAccount();
                break;
            case 4:
                WithdrawAccount();
                break;
            case 5:
                DeleteAccount();
                break;
            case 6:
                System.exit(0);
            default:
                System.out.println("Invalid");

            }

        }
    }

    private static void DeleteAccount() {
        System.out.println("Enter Accout NO :");
        int no = sc.nextInt();
        if (accounts.containsKey(no)) {
            accounts.remove(no);
            System.out.println("Account Deleted ");

        } else {
            System.out.println("Account not Found");
        }
    }

    private static void WithdrawAccount() {
        System.out.println("Enter account no :");
        int no = sc.nextInt();
        Account acc = accounts.get(no);
        if (acc != null) {
            System.out.println("Enter the Amount");
            double amount = sc.nextDouble();
            if (amount &amp;lt;= 0) {
                System.out.println("Invalid amount.");
                return;
            }
            if (acc.balance &amp;gt;= amount) {
                acc.balance -= amount;
                System.out.println("New Balance :" + acc.balance);
            } else {
                System.out.println("Insufficent Balance");
            }

        } else {
            System.out.println("Account not Found");
        }
    }

    private static void depositeAccount() {
        System.out.println("Enter account no :");
        int no = sc.nextInt();
        Account acc = accounts.get(no);
        if (acc != null) {
            System.out.println("Enter the Amount");
            double amount = sc.nextDouble();
            if (amount &amp;lt;= 0) {
                System.out.println("Invalid amount.");
                return;
            }
            acc.balance += amount;
            System.out.println("Deposited New Balance :" + acc.balance);

        } else {
            System.out.println("Account not Found");
        }
    }

    private static void viewAccount() {

        System.out.println("Enter Account NO:");
        int no = sc.nextInt();
        Account acc = accounts.get(no);
        if (acc != null) {
            System.out.println("Name :" + acc.name + " " + "balance :" + acc.balance);

        } else {
            System.out.println("Account not Found");
        }
    }

    private static void createAccount() {
        System.out.println("Enter Account Number :");
        int no = sc.nextInt();
        sc.nextLine();
        System.out.println("Enter Account Name :");
        String name = sc.nextLine();
        System.out.println("Enter Account intial Balance :");
        double balance = sc.nextDouble();
        if (accounts.containsKey(no)) {
            System.out.println("Account already exists!");
            return;
        }
        accounts.put(no, new Account(no, name, balance));
        System.out.println("Account Created");

    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:1.create&lt;br&gt;
2.view&lt;br&gt;
3.Deposit&lt;br&gt;
4.Withdraw&lt;br&gt;
5.Delete&lt;br&gt;
6.Exit&lt;br&gt;
1&lt;br&gt;
Enter Account Number :&lt;br&gt;
89&lt;br&gt;
Enter Account Name :&lt;br&gt;
neelakandan&lt;br&gt;
Enter Account intial Balance :&lt;br&gt;
892848&lt;br&gt;
Account Created&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>How the insert Method Works in This Java Linked List Functionality of insert</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Wed, 23 Jul 2025 05:00:02 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/how-the-insert-method-works-in-this-java-linked-list-functionality-of-insert-4kaf</link>
      <guid>https://forem.com/neelakandan_ravi/how-the-insert-method-works-in-this-java-linked-list-functionality-of-insert-4kaf</guid>
      <description>&lt;p&gt;Can you explain how the insert method works in this Java linked list implementation, and what role the head and tail pointers play in efficiently adding nodes to the list?&lt;/p&gt;

&lt;p&gt;The insert(int data) method creates a new node with the given integer value.&lt;/p&gt;

&lt;p&gt;If the list is empty (head == null), the new node becomes both the head and tail of the list.&lt;/p&gt;

&lt;p&gt;If the list already contains nodes, the new node is added to the end:&lt;/p&gt;

&lt;p&gt;The current tail node’s next pointer is updated to reference the new node.&lt;/p&gt;

&lt;p&gt;The tail pointer is then updated to point to the new node.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Interview_practice;

class Node {
    public Node(int data) {
        this.data = data;
    }

    int data;// 0
    Node next;// null
}

class link_list {
    Node head = null, tail = null;

    public void insert(int data) {

        Node n = new Node(data);
        n.next = null;// next null
        if (head == null) {
            head = n;
            tail = n;
        } else {
            tail.next = n;
            tail = n;
        }
    }

    public void display() {
        Node temp = head;
        while (temp != null) {
            System.out.print(temp.data + " ");
            temp = temp.next;
        }

    }
}

public class Linked_list {

    public static void main(String[] args) {
        link_list ls = new link_list();
        ls.insert(10);
        ls.insert(101);
        ls.insert(102);
        ls.insert(104);
        ls.display();
    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:10 101 102 104 &lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>payilagam</category>
      <category>interview</category>
    </item>
    <item>
      <title>CURD Operation in java using JDBC</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Sun, 20 Jul 2025 15:50:58 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/curd-operation-in-java-using-jdbc-3ll5</link>
      <guid>https://forem.com/neelakandan_ravi/curd-operation-in-java-using-jdbc-3ll5</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;First Create Database:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;neelakandan@neelakandan-HP-Laptop-15s-eq2xxx:~$ sudo -i -u postgres
[sudo] password for neelakandan:         
postgres@neelakandan-HP-Laptop-15s-eq2xxx:~$ psql
psql (16.9 (Ubuntu 16.9-0ubuntu0.24.04.1))
Type "help" for help.

postgres=# \c curd_op
You are now connected to database "curd_op" as user "postgres".
curd_op=# CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    name VARCHAR(100),
    email VARCHAR(100)
);
CREATE TABLE
curd_op=# \dt
         List of relations
 Schema | Name  | Type  |  Owner   
--------+-------+-------+----------
 public | users | table | postgres
(1 row)

curd_op=# select * from users;
 id | name | email 
----+------+-------
(0 rows)

curd_op=# GRANT ALL PRIVILEGES ON TABLE users TO neel0;
GRANT
curd_op=# ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO neel;
ALTER DEFAULT PRIVILEGES
curd_op=# ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO neel0;
ALTER DEFAULT PRIVILEGES
curd_op=# GRANT USAGE, SELECT, UPDATE ON SEQUENCE users_id_seq TO neel0;
GRANT
curd_op=# select * from users;
 id | name |    email    
----+------+-------------
  1 | neel | neel@ex.com
(1 row)



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;strong&gt;JDBC 5 Steps :&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
**&lt;br&gt;
Step 1:import driver**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.sql.*;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Load the driver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Establish the Connection&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String url = "jdbc:postgresql://localhost:5432/curd_op";
        String user = "neel0";
        String pass = "neel0";

            Connection con = DriverManager.getConnection(url, user, pass);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4:Create a Statement and ExecuteQuery&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String insert = "insert into users(name,email)values('neel','neel@ex.com')";
            con.createStatement().executeUpdate(insert);
            System.out.println("updated");

            ResultSet read = con.createStatement().executeQuery("select * from users");
            while (read.next()) {
                System.out.println(read.getString("name") + " " + read.getString("email"));
            }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5:Close the Connection&lt;/strong&gt;&lt;br&gt;
con.close();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Add PostgreSQL JDBC Driver to your project&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;Linux  use terminal to download: wget &lt;a href="https://jdbc.postgresql.org/download/postgresql-42.7.3.jar" rel="noopener noreferrer"&gt;https://jdbc.postgresql.org/download/postgresql-42.7.3.jar&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Eclipse&lt;/p&gt;

&lt;p&gt;Right-click your project in the Package Explorer.&lt;/p&gt;

&lt;p&gt;Select Build Path → Configure Build Path.&lt;/p&gt;

&lt;p&gt;In the dialog:&lt;/p&gt;

&lt;p&gt;Go to the Libraries tab.Click Add External JARs…Browse and select the downloaded postgresql-xx.jar file.Click Apply and Close.&lt;br&gt;
wget &lt;a href="https://jdbc.postgresql.org/download/postgresql-42.7.3.jar" rel="noopener noreferrer"&gt;https://jdbc.postgresql.org/download/postgresql-42.7.3.jar&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Code for JDBC CURD&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Interview_practice;

import java.sql.*;

public class curd_op {

    public static void main(String[] args) {
        String url = "jdbc:postgresql://localhost:5432/curd_op";
        String user = "neel0";
        String pass = "neel0";
        try {
            Connection con = DriverManager.getConnection(url, user, pass);
            System.out.println("connected");

            String insert = "insert into users(name,email)values('neel','neel@ex.com')";
            con.createStatement().executeUpdate(insert);
            System.out.println("updated");

            ResultSet read = con.createStatement().executeQuery("select * from users");
            while (read.next()) {
                System.out.println(read.getString("name") + " " + read.getString("email"));
            }
            String update = "update users set name='neelakandan' where id=1";
            con.createStatement().executeUpdate(update);
            System.out.println("updated");

            String delete = "delete from users where id =1";
            con.createStatement().executeUpdate(delete);
            System.out.println("deleted");
            con.close();

        } catch (SQLException e) {

            e.printStackTrace();
        }

    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
connected&lt;br&gt;
updated&lt;br&gt;
neel &lt;a href="mailto:neel@ex.com"&gt;neel@ex.com&lt;/a&gt;&lt;br&gt;
neel &lt;a href="mailto:neel@ex.com"&gt;neel@ex.com&lt;/a&gt;&lt;br&gt;
neel &lt;a href="mailto:neel@ex.com"&gt;neel@ex.com&lt;/a&gt;&lt;br&gt;
updated&lt;br&gt;
deleted&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbc_crud {
    public static void main(String[] args) {
        String url = "jdbc:postgresql://localhost:5432/mydb";
        String user = "neel";
        String pass = "neel1862";
        String[][] name = { { "Java", "Neel" }, { "Python", "Alice" }, { "C++", "Bob" }, { "Go", "Charlie" },
                { "Rust", "David" } };
        try {
            Connection con = DriverManager.getConnection(url, user, pass);
            Statement s = con.createStatement();
//          String insert="insert into users (book,author) values ('java','neel')";
//          s.executeUpdate(insert);
//          System.out.println("insert sucessful");

            PreparedStatement ps = con.prepareStatement("insert into users (book,author) values (?,?)");
            for (String[] book : name) {
                ps.setString(1, book[0]);
                ps.setString(2, book[1]);
                ps.addBatch();

            }
            ps.executeBatch();

            ResultSet rs = s.executeQuery("select * from users");
            while (rs.next()) {
                System.out.println(rs.getString("book") + " " + rs.getString("author"));

            }
            String update = "update users set book='notjava' where id=1";
            s.executeUpdate(update);
            System.out.println("updated");
            String delete = "delete from users where id=1";
            s.executeUpdate(delete);
            System.out.println("delete");

        } catch (SQLException e) {

            e.printStackTrace();
        }
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Java Neel&lt;br&gt;
Python Alice&lt;br&gt;
C++ Bob&lt;br&gt;
Go Charlie&lt;br&gt;
Rust David&lt;br&gt;
updated&lt;br&gt;
delete&lt;/p&gt;

</description>
      <category>programming</category>
      <category>jdbc</category>
      <category>database</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Java 8 Features</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Sat, 05 Jul 2025 16:31:05 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/java-8-features-f6p</link>
      <guid>https://forem.com/neelakandan_ravi/java-8-features-f6p</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Lambda Expression:()-&amp;gt;&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
It is a way to write method in short way and create  anonymous function.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;(a, b) -&amp;gt; a + b;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Functional Interfaces&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It should have only one abstract method and it can have any number static and default methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;
@FunctionalInterface
public interface contract {

    public int add(int a, int b);

    public static void sum()
    {}

    public static void sum22()
    {}

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

public class city {
    public static void main(String[] args) {
        contract sum=(a,b)-&amp;gt;a+b;
        System.out.println(sum.add(10, 20));

    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Predicate&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Predicate is a functional interface that takes an input of type T and returns a boolean value.It has methed &lt;strong&gt;test();&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.function.Predicate;

public class bredicate {
    public static void main(String[] args) {
        Predicate&amp;lt;Integer&amp;gt; p=(no)-&amp;gt;no&amp;gt;50;
        System.out.println(p.test(8));
    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Function:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
The Function interface is a functional interface provided by Java 8 that takes one input and returns one output.It has methed &lt;strong&gt;apply();&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function &lt;br&gt;
T – Input type&lt;br&gt;
R – Return type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.function.Function;

public class FunctionEXample {
    public static void main(String[] args) {
//      Function&amp;lt;String,Integer&amp;gt; p=(name)-&amp;gt;name.length();
//      System.out.println(p.apply("Neelakandan"));

        Function&amp;lt;String, String&amp;gt; p = (name) -&amp;gt; name.toLowerCase();
        System.out.println(p.apply("NEELAKANDAN"));

    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;What is Consumer?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consumer is a functional interface introduced in Java 8. It accepts a single input (of type T) and returns nothing (void).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.List;
import java.util.function.Consumer;

public class consumenEx {
    public static void main(String[] args) {
//  Consumer&amp;lt;String&amp;gt; p=(name)-&amp;gt;System.out.println(name.toLowerCase());
//  p.accept("NEELAKANDAN");

        Consumer&amp;lt;String&amp;gt; p = (name) -&amp;gt; System.out.println(name + " thanks");
        Consumer&amp;lt;String&amp;gt; p2 = (name) -&amp;gt; System.out.println(name + " hi");
        Consumer&amp;lt;String&amp;gt; p3 = p.andThen(p2);
        p3.accept("neel");// output :neel thanks neel hi

//      List al=List.of(10,20,30,40,50);
//      Consumer&amp;lt;Integer&amp;gt; p=(n)-&amp;gt;System.out.println("no = "+n);
//      
//      al.forEach(p);

//  output          no = 10
//              no = 20
//              no = 30
//              no = 40
//              no = 50

    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Supplier&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Supplier is a functional interface that doesn't take any input, but returns a value of type T&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.Random;
import java.util.function.Supplier;

public class suplier {
    public static void main(String[] args) {
        Random r = new Random();

        Supplier&amp;lt;Integer&amp;gt; s = () -&amp;gt; r.nextInt(100);
        System.out.println(s.get());
    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Stream:&lt;/u&gt;&lt;/strong&gt;is a new feauture in java8  that let you work with collection in a clear and shorted way.&lt;/p&gt;

&lt;p&gt;Stream api:processing collection of object.&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Arrays.stream();&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.stream.IntStream;

public class Streamof {
    public static void main(String[] args) {
        int[] ar= {10,20,50,1,30,40,50};
//      IntStream s=Arrays.stream(ar);
//      s=s.sorted();
//      s.forEach(System.out::println);

//      Arrays
//      .stream(ar)
//      .sorted()
//      .forEach(System.out::println);  

//      OptionalInt s=Arrays
//              .stream(ar)
//              .max();
//      System.out.println(s.getAsInt());//50


//      OptionalInt s=Arrays
//              .stream(ar)
//              .min();
//      System.out.println(s.getAsInt());//1



        OptionalDouble s=Arrays
                .stream(ar)
                .average();
        System.out.println(s.getAsDouble());//28.714285714285715


    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.Arrays;

public class arraystream {
    public static void main(String[] args) {
//      int[]ar={1,2,2,3,4,4,5,67,40};
//      Arrays
//      .stream(ar)
//      .distinct()//remove duplicate
//      .forEach(System.out::println);


//      long od=Arrays
//      .stream(ar)
//      .count();
//      System.out.println(od);//count find

//      Arrays
//      .stream(ar)
//      .filter(no-&amp;gt;no%4==0)//multiple of 4
//      .forEach(System.out::println);//
    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.ArrayList;
import java.util.List;

public class arraystream {
    public static void main(String[] args) {
    List&amp;lt;Integer&amp;gt; ls=new ArrayList&amp;lt;Integer&amp;gt;();
    ls.add(10);
    ls.add(100);
    ls.add(140);
    ls.add(120);
    ls.add(10);
    ls.add(5);
    ls.add(11);
//    System.out.println(
//          ls
//          .stream()
//          .count());

//          ls
//          .stream()
//          .distinct()//unique
//          .sorted()//sort
//          .forEach(System.out::println);

ls
    .stream()
    .distinct()//unique
    .map(no-&amp;gt;no%100==0)//false true false false false false
    .forEach(System.out::println);


    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.ArrayList;
import java.util.List;

public class arraystream {
    public static void main(String[] args) {
    List&amp;lt;String&amp;gt; ls=new ArrayList&amp;lt;String&amp;gt;();
    ls.add("ayan");
    ls.add("aya");
    ls.add("ayanan");
    ls.add("mayan");
    ls.add("nayan");


//    ls
//    .stream()
//    .distinct()//unique
//    .map(no-&amp;gt;no.toUpperCase())
//  .forEach(System.out::println);

//    ls
//    .stream()
//    .distinct()//unique
//    .filter(no-&amp;gt;no.startsWith("a"))//ayan//aya//ayanan
//  .forEach(System.out::println);


    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package java8_features;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class java8 {
    public static void main(String[] args) {
        List&amp;lt;Integer&amp;gt; ls = Arrays.asList(2, 3, 4, 5, 6, 5, 8);
        List&amp;lt;Integer&amp;gt; l = ls.stream()
                .filter(n -&amp;gt; n % 2 == 0)
                .map(n -&amp;gt; n * n)
                .collect(Collectors.toList());
        System.out.println(l);

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java8</category>
      <category>programming</category>
      <category>payilaga</category>
    </item>
    <item>
      <title>Multiplication Table Generator using HTML, CSS, and JavaScript</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Thu, 05 Jun 2025 04:08:08 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/multiplication-table-generator-using-html-css-and-javascript-17eb</link>
      <guid>https://forem.com/neelakandan_ravi/multiplication-table-generator-using-html-css-and-javascript-17eb</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt; Introduction&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this blog, I’ll walk you through a simple web project I created — a Multiplication Table Generator using basic web technologies like HTML, CSS, and JavaScript. It takes a number as input and generates its multiplication table from 1 to 10. This is a beginner-friendly project that helps understand user input, DOM manipulation, and basic styling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        body{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .layout{
            display: flex;
            flex-direction: column;
            gap: 20px;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="layout"&amp;gt;
        &amp;lt;h1&amp;gt;Multiplication Table Generator&amp;lt;/h1&amp;gt;
        &amp;lt;div class="input"&amp;gt;
            &amp;lt;label for=""&amp;gt;Enter a Number&amp;lt;/label&amp;gt;
            &amp;lt;input type="number" id="my-input"&amp;gt;
            &amp;lt;button onclick="generate_table()"&amp;gt;Generate&amp;lt;/button&amp;gt;
            &amp;lt;div id="result"&amp;gt;

            &amp;lt;/div&amp;gt;


        &amp;lt;/div&amp;gt;

    &amp;lt;/div&amp;gt;
    &amp;lt;script&amp;gt;
        let result="";
        function generate_table(){
          let number= parseInt(document.getElementById("my-input").value);
          if(isNaN(number))
          {
            result="Enter input invalid";
          }
          else{
            let i=1;
            let n=number;
            while(i&amp;lt;=10)
          {

            result+=${i} * ${n} = ${n*i}\n
            i++;
          }
          }

          document.getElementById("result").innerText=result;

        }
    &amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;OUTPUT:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fso6n6swbaajyysaou2qq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fso6n6swbaajyysaou2qq.png" alt="Image description" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>javascript</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>DOM and Array in JavaScript</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Mon, 02 Jun 2025 05:09:57 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/dom-and-array-in-javascript-39kn</link>
      <guid>https://forem.com/neelakandan_ravi/dom-and-array-in-javascript-39kn</guid>
      <description>&lt;p&gt;What is the DOM?&lt;/p&gt;

&lt;p&gt;The DOM is a programming interface provided by the browser that represents the structure of a web page as a tree of objects. Each element in an HTML document becomes a node (object) in this tree. JavaScript can use the DOM to access and manipulate HTML and CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;&amp;lt;title&amp;gt;My Page&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;h1 id="title"&amp;gt;Hello, DOM!&amp;lt;/h1&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let heading = document.getElementById("title");
heading.textContent = "Welcome to JavaScript DOM!";

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;What Does the HTML DOM Look Like?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine your webpage as a tree&lt;/p&gt;

&lt;p&gt;The document is the root.&lt;/p&gt;

&lt;p&gt;HTML tags like , &lt;/p&gt;, and  are branches.

&lt;p&gt;Attributes, text, and other elements are the leaves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Why is DOM Required?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dynamic Content Updates: Without reloading the page, the DOM allows content updates (e.g., form validation, AJAX responses).&lt;/p&gt;

&lt;p&gt;User Interaction: It makes your webpage interactive (e.g., responding to button clicks, form submissions).&lt;/p&gt;

&lt;p&gt;Flexibility: Developers can add, modify, or remove elements and styles in real-time.&lt;/p&gt;

&lt;p&gt;Cross-Platform Compatibility: It provides a standard way for scripts to interact with web documents, ensuring browser compatibility.&lt;/p&gt;

&lt;p&gt;Reference:&lt;a href="https://www.geeksforgeeks.org/html/dom-document-object-model/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/html/dom-document-object-model/&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;document&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The root object representing the whole HTML document.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;getElementById()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Selects an element by its ID.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;querySelector()&lt;/code&gt; / &lt;code&gt;querySelectorAll()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Select elements using CSS selectors.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;innerHTML&lt;/code&gt; / &lt;code&gt;textContent&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Get or set the content of elements.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;createElement()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create new HTML elements dynamically.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;appendChild()&lt;/code&gt; / &lt;code&gt;removeChild()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Add or remove elements.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;addEventListener()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Handle user interactions (e.g., clicks).&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Increasing and Decreasing Count:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;


        .elem{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: aqua;
        }
        .element{
            border: 1px solid blue;
            border-radius: 10px;
            width: 250px;
            height: 20vh;
            padding: 15px;
            text-align: center;
            background-color: wheat;

        }
        button{
            padding: 5px;
            border-radius: 10px;
            background-color: rgb(48, 48, 179);
            color: white;
            width: 80px;
            height: 5vh;
         }
         h1{
            font-size: 40px;
         }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

    &amp;lt;div class="elem"&amp;gt;

        &amp;lt;div class="element"&amp;gt;
            &amp;lt;h1 id="result"&amp;gt;&amp;lt;/h1&amp;gt;
    &amp;lt;button onclick="increase()"&amp;gt;+&amp;lt;/button&amp;gt;
    &amp;lt;button onclick="decrease()"&amp;gt;-&amp;lt;/button&amp;gt;
    &amp;lt;button onclick="reset()"&amp;gt;Reset&amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;script&amp;gt;
        let count=0;
        document.getElementById('result').innerHTML=count
function increase(){
count=count+1;
document.getElementById('result').innerHTML=count
}
function decrease(){
count=count-1;
document.getElementById('result').innerHTML=count
}
function reset(){
count=0;
document.getElementById('result').innerHTML=count
}

    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;What is array?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, an array is a special type of object used to store an ordered collection of elements. These elements can be of any data type, including numbers, strings, objects, and even other arrays. JavaScript arrays are dynamic, meaning their size can change, and they are zero-indexed, so the first element is accessed with index 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Create Array using Literal&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;let b = [10, 20, 30];&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt; Create using new Keyword &lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;let a = new Array(10, 20, 30);&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;What It Does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;push()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Adds item to end&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pop()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes last item&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;shift()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Removes first item&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;unshift()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Adds item to start&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;length&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Number of items in array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;includes()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Checks if an item exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;indexOf()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gets position of an item&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;join()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Joins all items into a string&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;slice()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Copies part of an array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;splice()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Adds/removes items at a position&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Changing BackGroundColor:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
      body{

        display: flex;
        justify-content: center;
        align-items: center;
        height: 60vh;
      }
      .hello{
        padding: 15px;
        border-radius: 5px;
        width: 20;
        background-color: red;
        color: white;
      }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
 &amp;lt;button class="hello" onclick="changecolor()"&amp;gt;Change Color&amp;lt;/button&amp;gt;   

 &amp;lt;script&amp;gt;
    function changecolor()
    {
let color=["white","blue","yellow","black"];
let len=color.length;
let randomNumber=Math.random()*len;
 let num=Math.floor(randomNumber);
 document.body.style.backgroundColor=color[num];
    }
 &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Global variables</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Thu, 29 May 2025 04:19:42 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/global-variables-2a6o</link>
      <guid>https://forem.com/neelakandan_ravi/global-variables-2a6o</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Global Variables&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Global variables in JavaScript are those declared outside of any function or block scope. They are accessible from anywhere within the script, including inside functions and blocks. *&lt;em&gt;Variables declared without the var, let, or const keywords (prior to ES6) inside a function automatically become global variables. *&lt;/em&gt;(TBD)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Key Characteristics of Global Variables:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scope: Accessible throughout the entire script, including inside functions and blocks.&lt;/p&gt;

&lt;p&gt;Automatic Global Variables: If a variable is declared inside a function without var, let, or const, it automatically becomes a global variable (a common source of bugs).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Local Variables&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Local variables are defined within functions in JavaScript. They are confined to the scope of the function that defines them and cannot be accessed from outside. Attempting to access local variables outside their defining function results in an error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Key Characteristics of Local Variables:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scope: Limited to the function or block in which they are declared.&lt;/p&gt;

&lt;p&gt;Function-Specific: Each function can have its own local variables, even if they share the same name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;How to use variables&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The scope of a variable or function determines what code has access to it.&lt;/p&gt;

&lt;p&gt;Variables that are created inside a function are local variables, and local variables can only be referred to by the code within the function.&lt;/p&gt;

&lt;p&gt;Variables created outside of functions are global variables, and the code in all functions has access to all global variables.&lt;/p&gt;

&lt;p&gt;If you forget to code the var keyword in a variable declaration, the JavaScript engine assumes that the variable is global. This can cause debugging problems.&lt;/p&gt;

&lt;p&gt;In general, it's better to pass local variables from one function to another as parameters than it is to use global variables. That will make your code easier to understand with less chance of errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let petName = 'Rocky' // Global variable
myFunction()

function myFunction() {
    fruit = 'apple'; // Considered global
    console.log(typeof petName +
        '- ' +
        'My pet name is ' +
        petName)
}

console.log(
    typeof petName +
    '- ' +
    'My pet name is ' +
    petName +
    'Fruit name is ' +
    fruit)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Refference:&lt;/strong&gt;&lt;a href="https://www.geeksforgeeks.org/global-and-local-variables-in-javascript/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/global-and-local-variables-in-javascript/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;What is the DOM?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The DOM defines a standard for accessing documents:&lt;/p&gt;

&lt;p&gt;"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."&lt;/p&gt;

&lt;p&gt;The W3C DOM standard is separated into 3 different parts:(TDB)&lt;/p&gt;

&lt;p&gt;Core DOM - standard model for all document types&lt;br&gt;
XML DOM - standard model for XML documents&lt;br&gt;
HTML DOM - standard model for HTML documents&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;What is the HTML DOM?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The HTML DOM is a standard object model and programming interface for HTML. It defines:&lt;/p&gt;

&lt;p&gt;The HTML elements as objects&lt;br&gt;
The properties of all HTML elements&lt;br&gt;
The methods to access all HTML elements&lt;br&gt;
The events for all HTML elements&lt;/p&gt;

&lt;p&gt;In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;getElementById() &lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The getElementById() method returns an element with a specified value.&lt;/p&gt;

&lt;p&gt;The getElementById() method returns null if the element does not exist.&lt;/p&gt;

&lt;p&gt;The getElementById() method is one of the most common methods in the HTML DOM. It is used almost every time you want to read or edit an HTML element&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>JavaScript,Method,Datatype</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Wed, 28 May 2025 04:04:19 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/javascriptmethoddatatype-3pnp</link>
      <guid>https://forem.com/neelakandan_ravi/javascriptmethoddatatype-3pnp</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;What is JavaScript ?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript is the world's most popular programming language.&lt;br&gt;
JavaScript is the programming language of the Web.JavaScript is easy to learn.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Why Study JavaScript?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript is one of the 3 languages all web developers must learn:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;HTML to define the content of web pages&lt;/li&gt;
&lt;li&gt;CSS to specify the layout of web pages&lt;/li&gt;
&lt;li&gt;JavaScript to program the behavior of web pages&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;What is function?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, a function is a block of code designed to perform a particular task. It allows you to reuse code, organize logic, and create modular applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Declaring a Function&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet() {
  console.log("Hello, world!");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Calling a Function&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
greet(); // Output: Hello, world!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Function with Parameters&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(a, b) {
  return a + b;
}

console.log(add(5, 3)); // Output: 8

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Function Expression&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const multiply = function(x, y) {
  return x * y;
};

console.log(multiply(4, 5)); // Output: 20

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5.Why Functions Are Useful&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Code reusability&lt;/p&gt;

&lt;p&gt;Modular design&lt;/p&gt;

&lt;p&gt;Easier debugging&lt;/p&gt;

&lt;p&gt;Improved readability&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;JavaScript has 8 Datatypes&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;String&lt;br&gt;
Number&lt;br&gt;
Bigint&lt;br&gt;
Boolean&lt;br&gt;
Undefined&lt;br&gt;
Null&lt;br&gt;
Symbol&lt;br&gt;
Object &lt;/p&gt;

&lt;p&gt;In JavaScript, &lt;strong&gt;let, const, and var&lt;/strong&gt; are used to declare variables, but they behave differently in terms of scope, hoisting, and mutability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. var (Old, avoid using it)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function-scoped&lt;br&gt;
Can be re-declared and updated&lt;br&gt;
Hoisted (initialized as undefined)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function testVar() {
  var x = 10;
  if (true) {
    var x = 20; // same variable
    console.log(x); // 20
  }
  console.log(x); // 20
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. let (Modern, preferred for variables that change)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Block-scoped&lt;br&gt;
Can be updated, but not re-declared in the same scope&lt;br&gt;
Hoisted, but not initialized (accessing before declaration gives error)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function testLet() {
  let y = 10;
  if (true) {
    let y = 20; // different variable
    console.log(y); // 20
  }
  console.log(y); // 10
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. const (Modern, for constants)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Block-scoped&lt;br&gt;
Cannot be updated or re-declared&lt;br&gt;
Must be initialized at declaration&lt;br&gt;
For objects/arrays, the reference is constant (you can still change properties)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const z = 30;
// z = 40; ❌ Error: Assignment to constant variable

const person = { name: "Alice" };
person.name = "Bob"; // ✅ Allowed: changing property
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In JavaScript, the **return&lt;/strong&gt; keyword is used inside a function to:**&lt;br&gt;
Stop the function execution.&lt;br&gt;
Send a value back to the place where the function was called.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Basic Syntax&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(a, b) {
  return a + b;
}

let result = add(5, 3);  // result = 8
console.log(result);     // Output: 8

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;strong&gt;parameters and arguments&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, &lt;strong&gt;parameters and arguments&lt;/strong&gt; are related to how functions receive data. They’re often confused, but they mean different things:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Parameters&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are placeholders in the function definition.&lt;br&gt;
They define what kind of input the function can take.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet(name) { // 'name' is a parameter
  console.log("Hello, " + name);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Arguments&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are the actual values you pass when calling the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greet("Alice"); // "Alice" is an argument
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example with Multiple Parameters and Arguments&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(a, b) { // a and b are parameters
  return a + b;
}

let sum = add(5, 3); // 5 and 3 are arguments
console.log(sum); // Output: 8


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>NumberGuessingGame with springBoot and java</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Sat, 17 May 2025 06:00:51 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/numberguessinggame-3ppi</link>
      <guid>https://forem.com/neelakandan_ravi/numberguessinggame-3ppi</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;NumberGuessingGame&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package pratice;

import java.util.Scanner;
import java.util.Random;

public class NumberGuessingGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Random random = new Random();

        int lowerBound = 1;
        int upperBound = 100;
        int numberToGuess = random.nextInt(101);
        int numberOfTries = 0;
        int userGuess = 0;

        System.out.println("🎮 Welcome to the Number Guessing Game!");
        System.out.println("I have selected a number between " + lowerBound + " and " + upperBound + ".");
        System.out.println("Can you guess it?");

        while (userGuess != numberToGuess) {
            System.out.print("Enter your guess: ");
            userGuess = scanner.nextInt();
            numberOfTries++;

            if (userGuess &amp;lt; numberToGuess) {
                System.out.println("Too low! Try again.");
            } else if (userGuess &amp;gt; numberToGuess) {
                System.out.println("Too high! Try again.");
            } else {
                System.out.println("🎉 Congratulations! You guessed the number in " + numberOfTries + " attempts.");
            }
        }

        scanner.close();
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🎮 Welcome to the Number Guessing Game!&lt;br&gt;
I have selected a number between 1 and 100.&lt;br&gt;
Can you guess it?&lt;br&gt;
Enter your guess: 56&lt;br&gt;
Too low! Try again.&lt;br&gt;
Enter your guess: 78&lt;br&gt;
Too high! Try again.&lt;br&gt;
Enter your guess: 65&lt;br&gt;
Too low! Try again.&lt;br&gt;
Enter your guess: 70&lt;br&gt;
Too low! Try again.&lt;br&gt;
Enter your guess: 72&lt;br&gt;
Too low! Try again.&lt;br&gt;
Enter your guess: 74&lt;br&gt;
Too low! Try again.&lt;br&gt;
Enter your guess: 76&lt;br&gt;
🎉 Congratulations! You guessed the number in 7 attempts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;SpringBoot NumberGuessingGame&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NumberGuessingGameApplication.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class NumberGuessingGameApplication {
    public static void main(String[] args) {
        SpringApplication.run(NumberGuessingGameApplication.class, args);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Controller&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Random;

@Controller
public class GameController {

    @GetMapping("/")
    public String home(HttpSession session, Model model) {
        if (session.getAttribute("numberToGuess") == null) {
            session.setAttribute("numberToGuess", new Random().nextInt(100) + 1);
            session.setAttribute("attempts", 0);
        }
        model.addAttribute("message", "Guess a number between 1 and 100");
        return "index";
    }

    @PostMapping("/guess")
    public String guess(@RequestParam int userGuess, HttpSession session, Model model) {
        int numberToGuess = (int) session.getAttribute("numberToGuess");
        int attempts = (int) session.getAttribute("attempts");

        attempts++;
        session.setAttribute("attempts", attempts);

        if (userGuess &amp;lt; numberToGuess) {
            model.addAttribute("message", "🔽 Too low! Try again.");
        } else if (userGuess &amp;gt; numberToGuess) {
            model.addAttribute("message", "🔼 Too high! Try again.");
        } else {
            model.addAttribute("message", "🎉 Correct! You guessed it in " + attempts + " attempts.");
            return "result";
        }

        return "index";
    }

    @PostMapping("/restart")
    public String restart(HttpSession session) {
        session.invalidate();
        return "redirect:/";
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In template Create index.html,result.html&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;index.html&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html xmlns:th="http://www.thymeleaf.org"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Number Guessing Game&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;🎮 Number Guessing Game&amp;lt;/h1&amp;gt;
    &amp;lt;p th:text="${message}"&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;form method="post" action="/guess"&amp;gt;
        &amp;lt;input type="number" name="userGuess" required min="1" max="100"/&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Guess&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;result.html&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html xmlns:th="http://www.thymeleaf.org"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Result&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h2 th:text="${message}"&amp;gt;&amp;lt;/h2&amp;gt;
    &amp;lt;form method="post" action="/restart"&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Play Again&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Result Page:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdo003tnacswz6jjldtm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdo003tnacswz6jjldtm.png" alt="Image description" width="637" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output Page&lt;/u&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpj0wh5riel5e9v2tmxjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpj0wh5riel5e9v2tmxjs.png" alt="Image description" width="800" height="44"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>fullstack</category>
      <category>payilagam</category>
    </item>
    <item>
      <title>Remove Vowel-java,PasswordValidator,Regex,Password Valitation</title>
      <dc:creator>Neelakandan R</dc:creator>
      <pubDate>Thu, 15 May 2025 06:19:39 +0000</pubDate>
      <link>https://forem.com/neelakandan_ravi/remove-vowel-java-33ph</link>
      <guid>https://forem.com/neelakandan_ravi/remove-vowel-java-33ph</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;1)Remove Vowel&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package pratice;

import java.util.Scanner;

public class Vowel {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        System.out.println("Enter word :");
        String sh=sc.nextLine();
        for(int i=0;i&amp;lt;sh.length();i++)
        {
            char ch=sh.charAt(i);
            if(!(ch=='a' &amp;amp;&amp;amp; ch=='A'||ch=='e' &amp;amp;&amp;amp; ch=='E'||ch=='i' &amp;amp;&amp;amp; ch=='I'||ch=='o' &amp;amp;&amp;amp; ch=='O'||ch=='u' &amp;amp;&amp;amp; ch=='U'))
            {
                System.out.print(ch+" ");
            }
        }
    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter word :&lt;br&gt;
salman guruji&lt;br&gt;
s l m n   g r j&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;2)Find Vowel:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package pratice;

import java.util.Scanner;

public class Vowel {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter word :");
        String sh = sc.nextLine();
        for (int i = 0; i &amp;lt; sh.length(); i++) {
            char ch = sh.charAt(i);
            if ((ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O'
                    || ch == 'u' || ch == 'U')) {
                System.out.print(ch + " ");
            }
        }
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Enter word :&lt;br&gt;
salman guruji&lt;br&gt;
a a u u i &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;3)PasswordValidator&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package pratice;

public class PasswordValidatorSimple {
    public static void main(String[] args) {
        String password = "Gbc123@";

        boolean upper = false;
        boolean lower = false;
        boolean number = false;
        boolean special = false;

        for (int i = 0; i &amp;lt; password.length(); i++) {
            char ch = password.charAt(i);

            if (ch &amp;gt;= 'A' &amp;amp;&amp;amp; ch &amp;lt;= 'Z') {
                upper = true;
            } else if (ch &amp;gt;= 'a' &amp;amp;&amp;amp; ch &amp;lt;= 'z') {
                lower = true;
            } else if (ch &amp;gt;= '0' &amp;amp;&amp;amp; ch &amp;lt;= '9') {
                number = true;
            } else {
                special = true;
            }
        }

        if (upper &amp;amp;&amp;amp; lower &amp;amp;&amp;amp; number &amp;amp;&amp;amp; special == true) {
            System.out.println("Password is valid");
        } else {
            System.out.println("Password is invalid");
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Password is valid&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;4)Regex&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Explanation of the Regex:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PR → starts with PR&lt;br&gt;
\d → digit (0–9), double backslash because Java needs to escape \&lt;br&gt;
{6} → exactly 6 digits&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class PRFormatChecker {
    public static void main(String[] args) {
        String input = "PR123456"; 

        String pattern = "PR\\d{6}";

        // Check if the input matches the pattern
        if (input.matches(pattern)) {
            System.out.println("Valid format");
        } else {
            System.out.println("Invalid format");
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PR123456&lt;/td&gt;
&lt;td&gt;Valid format&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PR12345&lt;/td&gt;
&lt;td&gt;Invalid format&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PX123456&lt;/td&gt;
&lt;td&gt;Invalid format&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PR123A56&lt;/td&gt;
&lt;td&gt;Invalid format&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;5)&lt;strong&gt;&lt;u&gt;Password Valitation:&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class PasswordValidatorSimple {
    public static void main(String[] args) {
        String password = "Abc123@";

        boolean upper = false;
        boolean lower = false;
        boolean number = false;
        boolean special = false;

        for (int i = 0; i &amp;lt; password.length(); i++) {
            char ch = password.charAt(i);

            if (ch &amp;gt;= 'A' &amp;amp;&amp;amp; ch &amp;lt;= 'Z') {
                upper = true;
            } else if (ch &amp;gt;= 'a' &amp;amp;&amp;amp; ch &amp;lt;= 'z') {
                lower = true;
            } else if (ch &amp;gt;= '0' &amp;amp;&amp;amp; ch &amp;lt;= '9') {
                number = true;
            } else {
                special = true;
            }
        }

        if (upper &amp;amp;&amp;amp; lower &amp;amp;&amp;amp; number &amp;amp;&amp;amp; special) {
            System.out.println("Password is valid");
        } else {
            System.out.println("Password is invalid");
        }
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Password is valid&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>payilagam</category>
    </item>
  </channel>
</rss>
