JAVA Programming Lab Experiments
JAVA Programming Lab Experiments
CSD 12302130601059
____________
C-13
SEM -4 24 25
Sr. Page
No Name of the Experiment Date No. Marks Signature
Basic Program
1. Study of class path and java runtime environment
01 2. Write a program to
Implement command line calculator
Write To prints Fibonacci series.
Array:
1. Define a class Array with following member
02 Field:
int data[];
Function:
Array( ) //create array data of size 10 Array(int
size) // create array of size size Array(int data[])
// initialize array with parameter array
void Reverse _an _array () //reverse element of
an array
int Maximum _of _array () // find maximum
element of array
int Average_of _array() //find average of element
of array
void Sorting () //sort element of array
void display() //display element of array
int search(int no) //search element and return
index else return -1
int size(); //return size of an array
05 Inner Class:
Define two nested classes: Processor and RAM
inside the outer class: CPU with following data
members
class CPU {
double price;
class Processor{ // nested class double
cores;
double catch()
String manufacturer;
double getCache()
void displayProcesorDetail() }
protected class RAM{ // nested protected class
// members of protected nested class
double memory;
String manufacturer;
Double clockSpeed;
double getClockSpeed()
void displayRAMDetail() }
}
1. Write appropriate Constructor and create
instance of Outer and inner class and call the
methods in main function
2. Write a program to demonstrate usage of static
inner class, local inner class and anonymous inner
class
Generics
06 1. Declare a class InvoiceDetail which accepts a type
parameter which is of type Number with following
data members
class InvoiceDetail {
private String invoiceName;
private N amount;
private N Discount
// write getters, setters and constructors }
Call the methods in Main class
2. Implement Generic Stack
3. Write a program to sort the object of Book class
using comparable and comparator interface. (Book
class consist of book id, title, author and publisher
as data members)
07 Exception Handing
1. Write a program for creating a Bank class, which
is used to manage the bank account of customers.
Class has two methods, Deposit () and withdraw ().
Deposit method display old balance and new
balance after depositing the specified amount.
Withdrew method display old balance and new
balance after withdrawing. If balance is not enough
to withdraw the money, it throws
ArithmeticException and if balance is less than
500rs after withdrawing then it throw custom
exception, NotEnoughMoneyException.
2. Write a complete program for calculation average
of n +ve integer numbers of Array A.
a. Read the array form keyboard
b. Raise and handle Exception if
08 Threading
1. Write a program to find prime number in given
range using both method of multithreading. Also run
the same program using executor framework
2. Assume one class Queue that defines queue of fix
size says 15.
● Assume one class producer which implements
Runnable, having priority NORM_PRIORITY +1
● One more class consumer implements Runnable,
having priority NORM_PRIORITY-1
● Class TestThread is having main method with
maximum priority, which creates 1 thread for
producer and 2 threads for consumer.
● Producer produces number of elements and put
on the queue. when queue becomes full it notifies
other threads.
Consumer consumes number of elements and
notifies other thread when queue become empty.
09 Collection API:
1. Write a program to demostrate user of ArrayList,
LinkedList ,LinkedHashMap, TreeMap and HashSet
Class. And also implement CRUD operation without
database connection using Collection API.
2. Write a program to Sort
Array,ArrayList,String,List,Map and Set
File Handling Using Java:
10
1. Write a programme to count occurrence of a
given words in a file.
2. Write a program to print it seltf.
3. Write a program to display list of all the files of
given directory
Networking :
11 1. Implement Echo client/server program using TCP
2. Write a program using UDP which give name of
the audio file to server and server reply with
content of audio file
12 GUI
1. Write a programme to implement an
investement value calculator using the
data inputed by user. textFields to be
included are amount, year, interest
rate and future value. The field “future
value” (shown in gray) must not be
altered by user.
Practical -1
Basic Program
public class A1 {
public static void main(String[] args) {
for(int i=0;i<10;i++){
[Link]("Rohannnnn");
}
}
}
Rohannnnn
Rohannnnn
Rohannnnn
Rohannnnn
Rohannnnn
Rohannnnn
Rohannnnn
Rohannnnn
Rohannnnn
Rohannnnn
2. Write a program to
● Implement command line calculator
import [Link];
public class A2 {
public static void main(String[] args) {
Page | 0
Programming with Java
(202044502)
int a, b;
switch (operator) {
case "+":
return a + b;
case "-":
return a - b;
case "*":
return a * b;
case "/":
if (b != 0) {
return (double) a / b;
} else {
[Link]("Error: Division by zero");
break;
default:
[Link]("Syntax Error");
Page | 1
Programming with Java
(202044502)
break;
}
return 0;
}
}
[Link](Fibonacci(i)+" ");
}
}
public static int Fibonacci(int n){
if(n==0||n==1){
return n;
} int fib1=Fibonacci(n-
1); int fib2=Fibonacci(n-
2); int fib=fib1+fib2;
Page | 2
Programming with Java
(202044502)
return fib;
}
}
Page | 3
Programming with Java
(202044502)
Practical-2
Array:
1. Define a class Array with following member
Field:
int data[];
Function:
Array( ) //create array data of size 10
Array(int size) // create array of size size
Array(int data[]) // initialize array with parameter array
void Reverse _an _array () //reverse element of an array
int Maximum _of _array () // find maximum element of array
int Average_of _array() //find average of element of array
void Sorting () //sort element of array
void display() //display element of array
int search(int no) //search element and return index else return -1
int size(); //return size of an array
Use all the function in main method. Create different objects with different
constructors.
import [Link].*;
public class Array {
Page | 4
Programming with Java
(202044502)
int left = 0;
int right = [Link] - 1;
while (left < right) {
}}
public int maximumArray() {
int max = data[0];
for (int i = 1; i < [Link]; i++) {
int sum = 0;
for (int value : data) {
sum += value;
}
return sum / [Link];
}
public void sorting() {
[Link](data);
Page | 5
Programming with Java
(202044502)
}
public void display() {
[Link]([Link](data));
}
public int search(int no) {
return [Link];
}
public static void main(String[] args) {
[Link]();
int max = [Link]();
int avg = [Link]();
int searchIndex = [Link](7);
[Link]("\nModified Arrays:");
[Link]();
Page | 6
Programming with Java
(202044502)
[Link](); [Link]();
[Link]("\nResults:");
[Link]("Maximum of array3: " + max);
[Link]("Average of array3: " + avg);
[Link]("Index of 7 in array3: " + searchIndex);
}}
Page | 7
Programming with Java
(202044502)
result
void displayMatrix(float [][]a) //display content of argument array
void displayMatrix() //display content
float maximum_of_array() // return maximum element of first array
float average_of_array( ) // return average of first array
create three object of Matrix class with different constructors in main and test all the
functions in main .
import [Link];
public class Matrix {
}
public Matrix(int row, int column) {
[Link] = row;
[Link] = column;
[Link] = new float[row][column];
Page | 8
Programming with Java
(202044502)
transpose[j][i] = [Link][i][j];
}
}
return transpose;
}
float[][] result = new float[[Link]][[Link]];
for (int i = 0; i < [Link]; i++) {
for (int j = 0; j < [Link]; j++) {
for (int k = 0; k < [Link]; k++) {
Page | 9
Programming with Java
(202044502)
}
[Link]();
}
Page | 10
Programming with Java
(202044502)
}
}
}
return max;
sum += [Link][i][j];
}
}
return sum / (row * column);
}
[Link]("Matrix 1:");
[Link]();
Page | 11
Programming with Java
(202044502)
[Link]("Matrix 2:");
[Link]();
[Link]("Matrix 3:");
[Link]();
[Link](product);
Page | 12
Programming with Java
(202044502)
[Link]("num1:"+num1);
[Link]("num2:"+num2);
int sum=[Link]()+[Link]();
[Link]("Sum: "+sum);
Page | 13
Programming with Java
(202044502)
Page | 14
Programming with Java
(202044502)
[Link]();
[Link]("Reversed String: " + [Link]());
Page | 15
Programming with Java
(202044502)
Practical-3
Basic Program using Class 1. Create a class BankAccount that has Depositor name ,
Acc_no, Acc_type, Balance as Data Members and void createAcc() . void Deposit(),
void withdraw() and void BalanceInquiry as Member Function. When a new Account
is created assign next serial no as account number. Account number starts from 1
import [Link].*;
public BankAccount() {
[Link] = nextAccountNumber++;
Page | 16
Programming with Java
(202044502)
[Link] = [Link]();
[Link]("Account created successfully!");
} else {
[Link]("Insufficient balance.");
}
}
Page | 17
Programming with Java
(202044502)
}}
2. Create a class time that has hour, minute and second as data members. Create a
parameterized constructor to initialize Time Objects. Create a member Function
Time Sum (Time, Time) to sum two time objects.
public class Time {
Page | 18
Programming with Java
(202044502)
}}
Page | 19
Programming with Java
(202044502)
3. Define a class with the Name, Basic salary and dearness allowance as data
[Link] and print the Name, Basic salary(yearly), dearness allowance
and tax deduced at source(TDS) and net salary, where TDS is charged on gross
salary which is basic salary + dearness allowance and TDS rate is as per following
table.
Gross Salary TDS
Rs. 100000 and below NIL
Above Rs. 100000 10% on excess over 100000
DA is 74% of Basic Salary for all. Use appropriate member function.
[Link] = name;
[Link] = basicSalary;
[Link] = 0.74 * basicSalary;
}
private double calculateGrossSalary() {
return 0;
} else {
return 0.1 * (grossSalary - 100000);
Page | 20
Programming with Java
(202044502)
}
}
private double calculateNetSalary() {
}
public static void main(String[] args) {
}
}
Page | 21
Programming with Java
(202044502)
Practical-4
Inheritance and interface
1. class Cricket having data members name, age and member methods display() and
setdata(). class Match inherits Cricket and has data members no_of_odi, no_of_test.
Create an array of 5 objects of class Match. Provide all the required data through
command line and display the information.
import [Link].*;
class Cricket {
String name;
int age;
void display(){
[Link]("Name: "+name);
[Link]("Age: "+age);
}
}
class Match extends Cricket{
int no_of_odi;
int no_of_test;
void displayMatchInto(){
display();
[Link]("Number of ODIs: "+no_of_odi);
Page | 22
Programming with Java
(202044502)
[Link](name, age);
match.no_of_odi = noOfODI;
match.no_of_test = noOfTest;
matches[i] = match;
Page | 23
Programming with Java
(202044502)
[Link]("Player Information:");
for (int i = 0; i < [Link]; i++) {
}}}
Page | 24
Programming with Java
(202044502)
double computePrice();
}
Page | 25
Programming with Java
(202044502)
@Override
public double computePrice() {
}
}
@Override
public double computePrice() {
}
}
Page | 26
Programming with Java
(202044502)
}
}
Page | 27
Programming with Java
(202044502)
}
public class Sphere implements ThreeDShape {
}
Define test class to call various methods of Geometric Shape
Program:
[Link]
public class Cone implements ThreeDShape {
[Link] = radius;
[Link] = height;
}
@Override
public double volume() {
Page | 28
Programming with Java
(202044502)
@Override
public void describe() {
[Link]("This is a cone.");
}
}
[Link]
public interface GeometricShape {
void describe();
}
[Link]
public class Rectangle implements TwoDShape {
[Link] = width;
[Link] = height;
}
@Override
public double area() {
[Link]("This is a rectangle.");
}
}
Page | 29
Programming with Java
(202044502)
[Link]
public class Sphere implements ThreeDShape {
[Link] = radius;
}
@Override
public double volume() {
[Link]("This is a sphere.");
}
}
[Link]
import [Link].*;
public class TestGeometricShapes {
Page | 30
Programming with Java
(202044502)
}
}
}
[Link]
public interface ThreeDShape extends GeometricShape {
double volume();
}
[Link]
public interface TwoDShape extends GeometricShape {
double area();
Page | 31
Programming with Java
(202044502)
Practical-5
Inner Class and packages:
Define two nested classes: Processor and RAM inside the outer class: CPU with following
data members
class CPU {
double price;
class Processor{ // nested class
double cores;
double catch()
String manufacturer;
double getCache()
void displayProcesorDetail()
}
protected class RAM{ // nested protected class
// members of protected nested class
double memory;
String manufacturer;
Double clockSpeed;
double getClockSpeed()
void displayRAMDetail()
}
}
1) Write appropriate Constructor and create instance of Outer and inner class and
call the methods in main function
class CPU {
double price;
class Processor{
Page | 32
Programming with Java
(202044502)
double cores;
String manufacturer;
}
double getCach(){
return 0.0;
}
void displayProcessorDetail(){
}
double getClockSpeed(){
return 0.0;
}
Page | 33
Programming with Java
(202044502)
void displayRAMDetail(){
[Link]("RAM Memory: "+ memory);
[Link]("RAM Manufacturer: "+ manufacturer);
[Link]("RAM Clock Speed: "+ clockSpeed);
}
}
}
public class Main1{
}
}
Page | 34
Programming with Java
(202044502)
Packages:
1) Implement a program that defines package figures, which has a class
circle inherited from a class shape in it. Include the methods in the class
to calculate area and display the necessary information. Also include a
class, which has main to carry out above-mentioned operations.
2) Create a package new_figures, which has classesrectangle and triangle
inherited from class shape of package figures. Thus import the package
[Link] out necessary operations tocalculate area and display the
necessary information.
3) Modify the above programs by importing both the packages in a file outside
both the packages, which contains main class.
Figures/[Link]
class CPU {
double price;
class Processor{
double cores;
String manufacturer;
[Link]=cores;
[Link]=manufacturer;
}
double getCach(){
return 0.0;
}
void displayProcessorDetail(){
[Link]("Processor Manufacturer"+manufacturer);
Page | 35
Programming with Java
(202044502)
double memory;
String manufacturer;
Double clockSpeed;
[Link]=memory;
[Link]=manufacturer;
[Link]=clockSpeed;
double getClockSpeed(){
return 0.0;
}
void displayRAMDetail(){
}
}
[Link]();
Page | 36
Programming with Java
(202044502)
[Link]();
}
Figures/[Link]
package figures;
New_figures/[Link]
package New_figures;
import [Link];
[Link] = width;
[Link] = height;
[Link]("Rectangle with width: " + width + " and height: " + height);
[Link]("Area: " + area());
}
}
Page | 37
Programming with Java
(202044502)
New_figures/[Link]
package New_figures;
import [Link];
[Link] = base;
[Link] = height;
[Link]("Triangle with base: " + base + " and height: " + height);
[Link]("Area: " + area());
Page | 38
Programming with Java
(202044502)
Practical-6
Generics
1. Declare a class InvoiceDetail which accepts a type parameter which is of type
Number with following data members
class InvoiceDetail <N extends Number> {
private String invoiceName;
private N amount;
private N Discount
// write getters, setters and constructors
}
Call the methods in Main class
import [Link];
// Constructor
public InvoiceDetail(String invoiceName, N amount, N discount) {
[Link] = invoiceName;
[Link] = amount;
[Link] = discount;
// Getters
public String getInvoiceName() {
return invoiceName;
Page | 39
Programming with Java
(202044502)
public N getAmount() {
return amount;
public N getDiscount() {
return discount;
}
// Setters
public void setInvoiceName(String invoiceName) {
[Link] = invoiceName;
}
}
}
public class Main1{
2. Write a program to sort the object of Book class using comparable and comparator
interface. (Book class consist of book id, title, author and publisher as data
members)
import [Link];
import [Link];
import [Link];
Page | 41
Programming with Java
(202044502)
// Getter methods
public int getId() {
return id;
}
return "Book{" +
"id=" + id +
", title='" + title + '\'' +
Page | 42
Programming with Java
(202044502)
}
}
return [Link]().compareTo([Link]());
}
}
[Link](book);
}
[Link]();
Page | 43
Programming with Java
(202044502)
[Link](book);
}
}
Page | 44
Programming with Java
(202044502)
Practical-7
Exception Handing
1. Write a program for creating a Bank class, which is used to manage the bank
account of customers. Class has two methods, Deposit () and withdraw (). Deposit
method display old balance and new balance after depositing the specified
amount. Withdrew method display old balance and new balance after
withdrawing. If balance is not enough to withdraw the money, it throws
ArithmeticException and if balance is less than 500rs after withdrawing then it
throw custom exception, NotEnoughMoneyException.
// Custom Exception for insufficient balance
class NotEnoughMoneyException extends Exception {
[Link] = balance;
}
balance += amount;
[Link]("Old Balance: " + oldBalance);
[Link]("New Balance after depositing " + amount + ": " + balance);
} else {
double oldBalance = balance;
balance -= amount;
[Link]("Old Balance: " + oldBalance);
[Link]("New Balance after withdrawing " + amount + ": " + balance);
if (balance < 500) {
}
}
try {
[Link](500);
[Link](800);
Page | 46
Programming with Java
(202044502)
} catch (ArithmeticException e) {
[Link]("Exception: " + [Link]());
} catch (NotEnoughMoneyException e) {
[Link]("Exception: " + [Link]());
}
}
try {
[Link]("Enter the number of elements in the array: ");
int n = [Link]();
Page | 47
Programming with Java
(202044502)
if (n <= 0) {
throw new IllegalArgumentException("Number of elements should be greater than
zero.");
}
int[] arr = new int[n];
double sum = 0;
[Link]("Enter the elements of the array:");
for (int i = 0; i < n; i++) {
arr[i] = [Link]();
if (arr[i] < 0) {
}
double average = sum / n;
[Link]("Average of the array elements: " + average);
} catch (IllegalArgumentException e) {
[Link]("Exception: " + [Link]());
}
[Link]();
Page | 48
Programming with Java
(202044502)
Practical-8
Threading
1. Write a program to find prime number in given range using both method of
multithreading. Also run the same program using executor framework.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public void run() {
for (int num = start; num <= end; num++) {
if (isPrime(num)) {
[Link](num);
}
}
Page | 49
Programming with Java
(202044502)
}
}
int startRange = 1;
int endRange = 100;
// Using Multithreading
int threads = [Link]().availableProcessors();
int chunk = (endRange - startRange + 1) / threads;
List<PrimeFinder> primeFinders = new ArrayList<>();
List<Thread> threadList = new ArrayList<>();
Page | 50
Programming with Java
(202044502)
Page | 51
Programming with Java
(202044502)
[Link]();
[Link](1, [Link]);
2. Assume one class Queue that defines queue of fix size says 15.
● Assume one class producer which implements Runnable, having priority
NORM_PRIORITY +1
● One more class consumer implements Runnable, having priority
NORM_PRIORITY-1
● Class TestThread is having main method with maximum priority, which
creates 1 thread for producer and 2 threads for consumer.
● Producer produces number of elements and put on the queue. when queue
becomes full it notifies other threads.
Consumer consumes number of elements and notifies other thread when queue become
empty.
Page | 52
Programming with Java
(202044502)
import [Link].*;
class Queue {
try {
wait();
} catch (InterruptedException e) {
[Link]();
}
}
[Link](element);
[Link]("Produced: " + element);
notifyAll();
} catch (InterruptedException e) {
[Link]();
Page | 53
Programming with Java
(202044502)
}
}
int element = [Link]();
[Link]("Consumed: " + element);
notifyAll();
return element;
}
}
@Override
public void run() {
for (int i = 1; i <= 20; i++) {
[Link](i);
try {
[Link](500);
} catch (InterruptedException e) {
[Link]();
}
}
}
}
Page | 54
Programming with Java
(202044502)
@Override
public void run() {
[Link]();
}
}
}
}
Page | 55
Programming with Java
(202044502)
[Link]();
[Link]();
[Link]();
try {
[Link]();
[Link]();
[Link]();
} catch (InterruptedException e) {
[Link]();
}
}
}
Page | 56
Programming with Java
(202044502)
Practical-9
Collection API:
1. Write a program to demostrate user of ArrayList, LinkedList ,LinkedHashMap,
TreeMap and HashSet Class.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
[Link]("ArrayList elements:");
for (String fruit : arrayList) {
[Link](fruit);
}
[Link]();
// LinkedList demonstration
LinkedList<String> linkedList = new LinkedList<>();
[Link]("Red");
Page | 57
Programming with Java
(202044502)
[Link]("Green");
[Link]("Blue");
[Link]("LinkedList elements:");
for (String color : linkedList) {
[Link](color);
}
[Link]();
// LinkedHashMap demonstration
LinkedHashMap<Integer, String> linkedHashMap = new LinkedHashMap<>();
[Link](1, "One");
[Link](2, "Two");
[Link](3, "Three");
[Link]("LinkedHashMap elements:");
for (Integer key : [Link]()) {
// TreeMap demonstration
TreeMap<Integer, String> treeMap = new TreeMap<>();
[Link](3, "Three");
[Link](1, "One");
[Link](2, "Two");
Page | 58
Programming with Java
(202044502)
// HashSet demonstration
HashSet<String> hashSet = new HashSet<>();
[Link]("Cat");
[Link]("Dog");
[Link]("Rabbit");
[Link]("HashSet elements (unordered):");
for (String animal : hashSet) {
[Link](animal);
}
[Link]();
}
}
Page | 59
Programming with Java
(202044502)
}
}
Page | 60
Programming with Java
(202044502)
Practical-10
File Handling Using Java:
1. Write a program to count occurrence of a given words in a file.
Create [Link] file
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
}
}
} catch (IOException e) {
[Link]();
Page | 61
Programming with Java
(202044502)
count++;
index = [Link](word, index + 1);
}
return count;
}
}
Page | 62
Programming with Java
(202044502)
String line;
while ((line = [Link]()) != null) {
[Link](line);
}
} catch (IOException e) {
[Link]();
}
}
}
if (files != null) {
for (File file : files) {
if ([Link]()) {
[Link]([Link]());
}
}
Page | 63
Programming with Java
(202044502)
} else {
[Link]("Directory does not exist or is not accessible.");
}
}
Page | 64
Programming with Java
(202044502)
Practical-11
Networking
1. Implement Echo client/server program using TCP
[Link]:
import [Link].*;
import [Link].*;
String line;
while ((line = [Link]()) != null) {
[Link](line);
[Link]("Server response: " + [Link]());
}
} catch (IOException e) {
[Link]();
}
}
Page | 65
Programming with Java
(202044502)
[Link]:
import [Link].*;
import [Link].*;
String line;
while ((line = [Link]()) != null) {
[Link](line);
[Link]("Server response: " + [Link]());
}
} catch (IOException e) {
[Link]();
}
Page | 66
Programming with Java
(202044502)
2. Write a program using UDP which give name of the audio file to server and server
reply with content of audio file.
➢ Client Code:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
[Link](fileContentPacket);
[Link](buffer, 0, bytesRead);
}
[Link]();
[Link]();
[Link]();
[Link]();
} catch (SocketException e) {
[Link]();
} catch (UnknownHostException e) {
[Link]();
} catch (IOException e) {
[Link]();
}
}
Page | 68
Programming with Java
(202044502)
}
➢ Server Code:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
Page | 69
Programming with Java
(202044502)
[Link](fileContentPacket);
[Link]();
} catch (SocketException e) {
[Link]();
} catch (IOException e) {
[Link]();
}
}
}
Page | 70
Programming with Java
(202044502)
Practical-12
GUI
1. Write a program to implement an investment value calculator using the data
inputted by user. text Fields to be included are amount, year, interest rate and
future value. The field “future value” (shown in gray) must not be altered by user.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
} catch (Exception e) {
[Link]();
}
}
});
}
public InvestmentCalculator() {
initialize();
}
Page | 72
Programming with Java
(202044502)
Page | 73
Programming with Java
(202044502)
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e) {
double amount = [Link]([Link]());
int year = [Link]([Link]());
double interestRate = [Link]([Link]());
}
});
}
}
2. Write a program which fill the rectangle with the selected color when button
pressed.
import [Link].*;
import [Link].*;
Page | 74
Programming with Java
(202044502)
public ColorFillButton() {
super("Color Fill Button");
setLayout(new FlowLayout());
add(rectanglePanel);
add(redButton);
add(greenButton);
add(blueButton);
[Link](this);
[Link](this);
[Link](this);
setSize(300, 150);
setVisible(true);
}
Page | 75
Programming with Java
(202044502)
selectedColor = [Link];
} else if ([Link]() == greenButton) {
selectedColor = [Link];
} else if ([Link]() == blueButton) {
selectedColor = [Link];
}
[Link](selectedColor);
[Link](); // Ensure immediate visual update
Page | 76