🌟 DOTWEB5.0 Tutorial
✨ UNIT‑1 : Introduction to DOTWEB5.0(OJ7) Programming Language
📘 Definition
DOTWEB5.0 is a programming language designed for code security and console-based software development. It is advanced, learnable, and applicable in various domains such as software development, remote applications (Remote X), web applications, and machine learning. It is symbolized by a star icon and works with frameworks like the Scroll Framework.
🧑💻 About DOTWEB5.0
DOTWEB5.0 was invented by Wilmix Jemin J in 2013, evolving from Java and DOTWEB3.0. Earlier versions of Java (JDK 1.7 and JDK 1.8) were vulnerable to source code extraction using tools like JAD decompiler. This inspired the creation of DOTWEB5.0 to enhance security and prevent easy reverse engineering.
Special thanks to Venkat, GitHub, and other supporters for their contributions.
⚠️ Limitations of Java and C#
Java class files are easily decompiled using JAD, making software vulnerable.
DOTWEB5.0 addresses this by translating .java7 files into secure DOTWEB5.0 class files, which are not easily understood by hackers.
It is not intended for GUI development (e.g., Java Swing).
🛠️ Can You Build a Compiler Like Java?
Yes. Using Java, you can build compilers for Java or other languages. While some may criticize this approach, it aligns with compiler design principles. The same applies to languages like C. However, the focus of DOTWEB5.0 is not on GUI frameworks like Java Swing or J2EE, due to concerns about misinformation and competitive sabotage.
🧪 Compiler Design History
At age 21, Wilmix Jemin J designed a compiler in VC++.
Later, he developed a mini compiler in Java.
🚀 Why Is DOTWEB5.0 More Advanced?
It uses fluent, English-like syntax similar to Java/J2EE.
It reduces lines of code significantly.
It supports camel case and integrates well with IDEs like IntelliJ.
The author opposes robot development due to ethical concerns but supports AI.
The OakJava8 module excels in mobile computing.
📦 DOTWEB5.0 Modules
DOTWEB5.0 is divided into two modules:
Module 1
Module 2
Module Overview
DOTWEB5.0 keywords resemble Java, making it easy for Java professionals to adopt. It supports console applications, web development, machine learning, data science, and Remote X applications. Module 1 is primarily used by Java and DOTWEB5.0 professionals. Remote X will be released after the completion of machine learning and data science modules.
📦 DotWeb5.0 Positioning Infographic (Text Outline)
┌───────────────────────────────┐
│ Mainstream Languages │
│ (Java, C#, PostgreSQL) │
└───────────────────────────────┘
│
│ Limitations:
│ - Security gaps
│ - Slower adoption of new paradigms
│ - Complex learning curve
▼
┌───────────────────────────────────────────────────────────┐
│ DotWeb5.0 Programming Language │
│ │
│ ✔ Security First: Unbreakable code protection │
│ ✔ Advanced OOP: Multiple inheritance, operator overload │
│ ✔ Versatility: Web, console, ML, data science │
│ ✔ Integration: Works with Java frameworks │
│ ✔ Performance: Faster execution, optimized memory │
└───────────────────────────────────────────────────────────┘
│
│ Complementary Innovation
▼
┌───────────────────────────────────────────────────────────┐
│ WNOSQLDb Database │
│ │
│ ✔ Best in Security: Stronger than PostgreSQL/Oracle │
│ ✔ Large Volume Handling: Scales beyond mainstream DBs │
│ ✔ Advanced Features: Modern NoSQL + enterprise strength │
│ ✔ Ease of Use: Developer‑friendly design │
└───────────────────────────────────────────────────────────┘
🔑 Reserved Keywords in DOTWEB5.0 (Module 1)
These keywords cannot be used as variable names, method names, class names, or other identifiers.
abstract
assert
boolean
break
byte
case
char
continue
default
do
while
double
else
enum
<---
final
float
for
if
-->
instanceof
int
interface
long
native
new
private
protected
public
return
short
switch
synchronized
throw
throws
transient
void
volatile
while
🧪 Sample Program: testme.java7
testme.java7
<JAVA7>
public <CLASS> testme
//--> Runnable
<--- <Thread>
<%
public <SHARED> int sum()
{
int b;
return(2+3);
}
public synchronized void <RUN>
{
<TRY>
{
<PRINTLINE>(" Under Weight is less than 15 your health is worst ="+sum());
<Thread>.sleep(1000);
throw new Exception();
}
<CATCH> (Exception e)
{
<PRINTLINE>(""+e);
}
}
<MAIN>
<%
<TRY>
{
testme t <NEW> testme();
t.start();
testme t1 <NEW> testme();
t1.start();
int value = 15;
if (value >=15)
{
assert value >= 25 : " Underweight";
<PRINTLINE>(" value is " + value);
}
else
{
<PRINTLINE>(" Under Weight is less than 15");
}
}
<CATCH> (Exception e)
{
<PRINTLINE>(""+e);
}
<FINALLY>
{
<PRINTLINE>(" note: please enter accurately");
}
%>
</JAVA7>
🖥️ Output
Value is 15
Underweight is less than 15.
Your health is poor = 5
Underweight is less than 15.
Your health is poor = 5
Note: Please enter accurately
java.lang.Exception
java.lang.Exception
💎 DotWeb5.0 Reserved Keywords – Module 2
DotWeb5.0 defines a set of reserved keywords that cannot be used as variable names, method names, class names, or other identifiers. In Module 2, we focus on developing prototype software (e.g., .exe files) for console-based DotWeb5.0 applications. This module is designed to be accessible for professionals familiar with DotWeb5.0, Java, and J2EE.
🔑 Reserved Keywords Overview
DotWeb5.0 includes 50 reserved keywords. Below is a summary of their purpose:
<ABSTRACT>
-> Abstract class can be created using <ABSTRACT> keyword.
<BREAK> -> Break out of loop
<CASE> -> Case keyword is used as option with Switch statement.
<CATCH> => It is used to catch Exceptions.
<CLASS> -> Class is the collection of objects
<CONTINUE> -> Continue with in a loop
<DO> --- <WHILE> -> <DO> keyword is used with While loop. While will continue executes statements in the block
until the condition in while is true.
<ELSE> -> <ELSE> key word is followed after <IF> statement
<ENUM> =>
An enum is a special "class" that represents a group of constants (unchangeable/read-only variables).
<FINALLY> => The Keyword <FINALLY> is used in finally block. It did not mind whether there is catch block present or not. It will always execute...
<FOR> => This keyword is used for Forloop.
<FOREACH> =>
The foreach loop is used to iterate over the elements of the collection.
The collection may be an array or a list or set.
It executes for each element present in the array.
<GOTO> goto => <GOTO> keyword is used with labels.
<IF> => <IF> keyword is for condition purpose
is => The is keyword operator is used to check if the run-time type of an object is compatible with the given type or not.
It returns true if the given object is of the same type otherwise, return false. It also returns false for null objects.
<IN> => It is used for the given element is present or not.
<OBJECT> => object are the instance of the class that
are created to use the attributes and methods of a class.
<INTERFACE> => Interface is used multiple inheritance
<DEFAULT> => Default Keyword is used with the switch statement.
<BASE> => base keyword, we can call the base class method also. It is useful if base and derived classes defines same method.
In other words, if method is overridden.
<LOCK> =>
Lock keyword ensures that one thread is executing a piece of code at one time. The lock keyword ensures that one thread does not enter a critical section of code while another thread is in that critical section.
<PACK> => <PACK> keyword means PACKAGE in DotWeb5.0.
A package is a namespace that organizes a set of related classes and interfaces.
<NEW> => It is used to create a object of the class.
<OPERATOR> => It is used for Operator loading.
<READONLY> =>
The readonly keyword can be used to define a variable or an object as readable only.
This means that the variable or object can be assigned a value at the class scope
or in a constructor only. You cannot change the value or reassign a value to a readonly variable
or object in any other method except the constructor.
<RET> -> Return the Value of any type
<SIZEOF> => The sizeof operator returns the number of bytes occupied by a variable of a given type.
<TYPEOF> => It is used to get a Type object representing String.
void => Void type means we can call the method in the main program section.It have no return type.
Shared => If a class is static and it contains any userdefined methods. That can be called in main class
without creating a Object. eg) student is the static class which contains display method.Then
how it can be called , that can be achieved using student.display().
<STR> => <STR> keyowrd is String in DotWeb5.0
<STRUCT> => This keyword represents structure of records.
<SWITCH> => switch keyword is used to select one of many code blocks to be executed.
<IS> => <IS> keyword represent this
<TRY> => This represent try block
<THROW> => This is used to throw the exception
<USE> => This is used to call any DotWeb5.0 libraries or DotWeb5.0 packages and we can reuse it.
<VIRTUAL> =>
virtual method is a method that can be overridden in a derived class. When a method is declared as
virtual in a base class, it allows a derived class to provide its own implementation of the method.
<VOLATILE> => This keyword represent synchronization happen at variable. All threads can access the
Volatile variable.
<WHILE> => This keyword represent while loop
<JAVA7> => This keyword is used to load io packages.Which will b used with Java/J2ee professionals.
<JAVA> => This keyword is used to load io packages, used to create a prototype console and web application ,etc.
<HEAPJ7> => HeapJ7 keyword respresent we can store any objects contains millions of data by using the J7heap. It is used to avoid Memmory overflow...
<CONVERTARRAYLIST> ,J7mem.ConverttoArrayList => This ConverttoArrayList method is used to convert string to arraylist.
<OVERRIDE> => This keyword is used to override the method of parent class.
bool => This keyword will be used to hold the true or false value.The bool indicates boolean in DotWeb5.0. eg) bool a =true; bool b=false;
get and set => get keyword is used for retrieving data. And set is used for setting value.
<OAKJAVA7SECURITY> => This is use to maintain security for DotWeb5.0 executable file.
=========================================================================================================
💠 Diamond Modules
DotWeb5.0 Module-1 and Module-2 are collectively referred to as the Diamond Module, supporting .java7 programs. When compiled using the DOTWEB5.0 compiler, a .java7 file produces both .jclass and .exe outputs. DOTWEB5.0 is open-source and available for DotWeb5.0 professionals.
A third module focused on security is available in the DotWeb5.0 Enterprise Edition.
⚙️ DotWeb5.0 Structure
What Is a Structure?
A structure is a value-type data construct that allows a single variable to hold related data of various types.
Syntax
AccessModifier StructureName {
// Structure block contains:
// Fields, Parameterized constructors, Constants, Properties,
// Various data types, and Methods
}
📘 Example: Copying Structure Data
Goal: Create a structure named Person with fields Name, Age, and Weight. Assign values and copy data from one structure to another.
Filename: j7samplestructure.java7
// DotWeb5.0 program to illustrate structure copying StructApplication
<JAVA>
// DotWeb5.0 program to illustrate copy the structure
<PACK> StructApplication {
// Defining structure
public <STRUCT> Person
{
// Declaring different data types
public string Name;
public int Age;
public int Weight;
}
<CLASS> JITs {
// Main Method
public void main()
{
// Declare P1 of type Person
Person P1;
// P1's data
P1.Name = "Wilmix Jemin";
P1.Age = 21;
P1.Weight = 58;
// Declare P2 of type Person
Person P2;
// Copying the values of P1 into P2
P2 = P1;
// Displaying the values of P1
<PRINTLN>("Values Stored in P1");
<PRINTLN>("Name: " +P1.Name);
<PRINTLN>("Age: " +P1.Age);
<PRINTLN>("Weight: " +P1.Weight);
<PRINTLN>("");
// Displaying the values of P2
<PRINTLN>("Values Stored in P2");
<PRINTLN>("Name: " +P2.Name);
<PRINTLN>("Age: " +P2.Age);
<PRINTLN>("Weight: " +P2.Weight);
}
}
}
🖥️ Output
Values Stored in P1
Name: Wilmix Jemin
Age: 21
Weight: 58
Values Stored in P2
Name: Wilmix Jemin
Age: 21
Weight: 58
✨ Operator Overloading in DotWeb 5.0
📘 What Is Operator Overloading?
In DotWeb 5.0, operator overloading allows developers to redefine the behavior of standard operators (like +, -, *, /) for user-defined types. This is achieved using a special method called an operator function.
🔧 Key Characteristics of Operator Functions
Must be declared as public static
Use the keyword operator followed by the operator symbol
Accept one argument for unary operators and two for binary operators
🧾 Syntax
public static return-type operator op (argument list)
op is the operator to be overloaded
operator is a required keyword
🧪 Example Program: Operator Overloading in DotWeb 5.0
This example demonstrates how to overload binary operators (, , , ) for a custom class.
📄 File: Calculator.java
<JAVA>
<PACK> calcpackage {
<CLASS> Calculator {
public int number = 0;
// no-argument constructor
public Calculator() {}
// parameterized constructor
public Calculator(int n)
{
number = n;
}
// Overloading of Binary "+" operator
public Shared Calculator <OPERATOR>+ (Calculator Calc1,Calculator Calc2)
{
Calculator Calc3 <NEW> Calculator(0);
Calc3.number = Calc2.number + Calc1.number;
return Calc3;
}
// Overloading of Binary "-" operator
public Shared Calculator <OPERATOR>- (Calculator Calc1,Calculator Calc2)
{
Calculator Calc3 <NEW> Calculator(0);
Calc3.number = Calc2.number - Calc1.number;
return Calc3;
}
// Overloading of Binary "*" operator
public Shared Calculator <OPERATOR>* (Calculator Calc1,Calculator Calc2)
{
Calculator Calc3 <NEW> Calculator(0);
Calc3.number = Calc2.number * Calc1.number;
return Calc3;
}
// Overloading of Binary "/" operator
public Shared Calculator <OPERATOR>/ (Calculator Calc1,Calculator Calc2)
{
Calculator Calc3 <NEW> Calculator(0);
Calc3.number = Calc1.number / Calc2.number;
return Calc3;
}
// function to display result
public void Print()
{
<PRINTLN>("{0}", number);
}
}
<CLASS> CalNum {
// Driver Code
public void main()
{
Calculator num1 <NEW> Calculator(500);
Calculator num2 <NEW> Calculator(80);
Calculator num3 <NEW> Calculator();
<PRINTLN>("------------------------------------");
num3 = num1 + num2;
num1.Print(); // Displays 500
num2.Print(); // Displays 80
num3.Print(); // Displays 580
<PRINTLN>("------------------------------------");
num3 = num1 - num2;
num3.Print();
<PRINTLN>("------------------------------------");
num3 = num1 * num2;
num3.Print();
<PRINTLN>("------------------------------------");
num3 = num1 / num2;
num3.Print();
}
}
}
🖥️ Output
------------------------------------
500
80
580
------------------------------------
420
------------------------------------
40000
------------------------------------ 6
🌐 DotWeb5.0 Error Documentation
📘 Module 1: Basic Error Handling
Module 1 is straightforward. Whenever an error occurs, it is automatically logged in the out.txt file located in the directory where the oakjava7 files reside.
There is no need for in-depth study—just practice, and you’ll grasp it quickly.
📘 Module 2: Error Code Reference
This document provides detailed explanations for each DotWeb5.0 error code.
For example, when compiling a program using Webc7 .java7 or .web extension, an error such as int c = 100 / 0; will trigger a message box displaying:
Line No: [X] Error Code: J70020 → Division by constant zero
Similar error models exist for other types of errors.
🧪 Running DotWeb5.0 in JShell (Instead of Command Prompt)
Follow these steps to run DotWeb5.0 using JShell:
Launch JShell
Double-click the Jshell.bat file in your folder.
In this example, .java7 files are stored in the wilmix7 directory.
Alternatively, create a .bat file that runs Java7Shell.exe and includes the path C:/oakjava7/src.
Compile and Run
Navigate to your working directory (e.g., C:/wilmix7).
Use JShell to compile .java7 files. DotWeb5.0 will compile and execute them, producing .class and .jclass files.
These files are used for rendering scrollable web pages (web applications).
For best results, compile .java7 files using the Visual Studio Command Prompt.
⚠️ Error Codes and Their Explanations
📘 Unit 2: Program Structures in DotWeb5.0
DotWeb5.0 introduces a unique programming model that differs from traditional Java. Below are the key syntax structures and examples to help you understand and implement DotWeb5.0 programs effectively.
🧩 SYNTAX 1: Basic DotWeb5.0 Program Structure
Filename: Filename.java7
public class <classname> {
// Mandatory constructor with super() call
public <classname> ()
{ super(); }
// Main method for DotWeb5.0 logic
public void main()
{ }
}
✅ Example: Query3.java7
class Query3
{ public Query3()
{ super(); }
// Method to display HTML content
public void displayHtmlToWeb(String a){
print("\n\n"); print("Welcome!" + a); print("\n\n");
}
// DotWeb5.0 main method (not static)
public void main()
{
displayHtmlToWeb(" to Everybody");
}
}
🔍 Note: This structure resembles Java Servlets and is available only in the Enterprise Edition. The compiled class file is sealed as: "DotWeb5.0 (JAVA7.0) Compiler - Jemin Information Technology - JIT-777-WRIT-0003 Query3.class" This type of program is referred to as a DotWeb5.0 Servlet.
🧩 SYNTAX 2: Package-Based Structure
Filename: Filename.java7
<JAVA>
<USE> packages;
<PACK> packagename
{
<CLASS> <classname>
{
public void main()
{
<! source code !>
}
}
}
🧩 SYNTAX 3: JAVA7-Based Structure
Filename: Filename.java7
<JAVA7>
<Access modifiers> <CLASS> <classname>
{
<MAIN> // it means it cannot be run in jdk1.8 compiler
<%
<! OAKJAVA7 Logic !>
%>
</JAVA7>
🧱 DotWeb5.0 Program Structure Breakdown
JAVA7.0 SYNTAX-1 Program Structure(.java7)
Declaration DotWeb5.0 Section :
public class <classname>
{
//This constructor with super method is mandatory, which indicates it is a DotWeb5.0
//program and class name and constructor name should be same
public <classname>()
{
super();
}
Documentation Section
// it means it will not support any java compiler, it is entirely different.
Package Statement;
Import Statement;
DotWeb5.0 LOGIC SECTION
// DotWeb5.0 main method should have public void main method otherwise DotWeb5.0
program will not compile....
public void main()
{
<! DotWeb5.0 Logic !>
}
CLOSE DotWeb5.0 LOGIC SECTION }
LOGIC DotWeb5.0 DATASTRUCTURE SECTION
class <CLASSNAME>
{
private <CLASSNAME>()
{
super();
}
................
................
................
CLOSE LOGIC DotWeb5.0 DATASTRUCTURE SECTION }
ENDING SECTION :
🔍 Explanation
All DotWeb5.0 should start DotWeb5.0 declaration section as
public class <classname>
{
//This constructor with super method is mandatory, which indicates it is a DotWeb5.0 program.
The class name and constructor of DotWeb5.0 program should be same.
public <classname>()
{
super();
}
after that DotWeb5.0 LOGIC SECTION should be
public void main()
{
<! DotWeb5.0 Logic !>
}
so <!DotWeb5.0 Logic> may have print statements, for loop,
Datastructure statements belong to another class.
But Logic DotWeb5.0 DataStructure Section should be in this format
class <CLASSNAME>
{
private <CLASSNAME>()
{
super();
}
and Close Logic DotWeb5.0 DataStructure section by using curly braces which is "}".
I hope this syntax change will be easy to follow and to do programming
in DotWeb5.0. I remove the complexity of the DotWeb5.0 program syntax. So now
this type of DotWeb5.0 servlet syntax is learnable.
SYNTAX 2: Enterprise Edition Format
Filename: Filename.java7
DotWeb5.0 SYNTAX-2 Program Structure
Beginning Section : <JAVA>
Documentation Section
Package Statement;
<USE> Statement;
<PACK> packagename
LOGIC SECTION
<CLASS> <classname>
{
public void main()
{
<! source code !>
}
CLOSE LOGIC SECTION
ENDING SECTION : }
🔍 Explanation
DotWeb5.0 Ending section is } ; Ending your DotWeb5.0 program
Documentation Section means you can include description
with comments.
Package statement means you had to include DotWeb5.0 program in Package ....
<USE> statement to import all the packages.
Interface statement for supporting multiple inheritance.
Logic section for writing DotWeb5.0 logic with Class followed by main method .
after writing logic close the logic section.
🧾 SYNTAX 3: JAVA7 Format
Filename: Filename.java7
Beginning Section : <JAVA7>
Documentation Section
Package Statement;
Import Statement;
LOGIC SECTION
<Access modifiers> <CLASS> <classname>
{
<MAIN>
{
<! source code !>
}
CLOSE LOGIC SECTION
ENDING SECTION : </JAVA7>
🔍 Explanation
All DotWeb5.0 should start with <JAVA7> then after that followed by <CLASS> <classname>
But <MAIN> is used instead for
public static void main(String args[]) for protection from hackers.
Logic section for writing DotWeb5.0 logic with Class followed by main method .
after writing logic close the logic section.
🔢 Example: Print Numbers from 0 to 99
Filename: display2.java7
<JAVA7>
public <CLASS> display2
{
<MAIN>
<%
for (int i=0;i<100;i++)
{
<PRINTLINE>(""+i);
}
%>
</JAVA7>
🖨️ Output
0 1 2 ... 99
📘 DotWeb5.0 Major Program (Java7 Collections Example)
Programs1.java7
<JAVA>
<USE> <WEB7>.IO; //<WEB7>-io packages
<USE> CUTIL; //Web7 cutil packages
<PACK> BoxApplication
{
<CLASS> Box
{
private double length; // Length of a box
private double breadth; // Breadth of a box
private double height; // Height of a box
public void setLength( double len )
<%
length = len;
}
public void setBreadth( double bre )
<%
breadth = bre;
}
public void setHeight( double hei )
<%
height = hei;
}
public double getVolume()
<%
return length * breadth * height;
}
}
<CLASS> Boxtester
{
public void main()
{
Box Box1 <NEW> Box(); // Declare Box1 of type Box
Box Box2 <NEW> Box();
double volume;
// Declare Box2 of type Box
// box 1 specification
Box1.setLength(6.0);
Box1.setBreadth(7.0);
Box1.setHeight(5.0);
// box 2 specification
Box2.setLength(12.0);
Box2.setBreadth(13.0);
Box2.setHeight(10.0);
// volume of box 1
volume = Box1.getVolume();
<PRINTLN>("Volume of Box1 :" +volume);
// volume of box 2
volume = Box2.getVolume();
// <PRINTLN>("Volume of Box2 : {0}", volume);
// Console.ReadKey();
CUTIL.ArrayList x <NEW> CUTIL.ArrayList();
// test size
<PRINTLN>("Initial size is " + x.size());
// test isEmpty
if (x.isEmpty())
<PRINTLN>("The list is empty");
else <PRINTLN>("The list is not empty");
// test put into ArrayList
x.add(0, Java7Collection.QUERY()); // get previous data from java7collection and put it into java7-arraylist at 0 location.
x.add(1, (6));
x.add(0, (1));
x.add(2, (4));
<PRINTLN>("List size is " + x.size());
// test toString
<PRINTLN>("The list is " + x);
String JAVA5 = "Java 5";
String JAVA6 = "Java 6";
String JAVA7 = "Java 7";
int c=1;
switch (c) {
case 1:
<PRINTLN>(JAVA5);
break;
case 2:
<PRINTLN>(JAVA6);
break;
case 3:
<PRINTLN>(JAVA7);
break;
}
<TRY>
{
Java7Collection.InsertQUERY(x.ToString());// insert arraylist at java7 collection memory
Java7Collection.QUERY(x.ToString(),"display23");// merge the output display23.java7.exe output with arraylist
}
<CATCH> (<EXE> e) {}
// test indexOf
int index = x.indexOf((4));
if (index < 0)
<PRINTLN>("4 not found");
else <PRINTLN>("The index of 4 is " + index);
index = x.indexOf((3));
if (index < 0)
<PRINTLN>("3 not found");
else <PRINTLN>("The index of 3 is " + index);
// test get
<PRINTLN>("Element at 0 is " + x.get(0));
<PRINTLN>("Element at 3 is " + x.get(3));
// test remove
<PRINTLN>(x.remove(1) + " removed"); //arraylist data removed
<PRINTLN>("The list is " + x);
<PRINTLN>(x.remove(2) + " removed");// 6 is removed
<PRINTLN>("The list is " + x);
if (x.isEmpty())
<PRINTLN>("The list is empty");
else <PRINTLN>("The list is not empty");
<PRINTLN>("List size is " + x.size());
}
}
}
✨ Explanation
Used Standard OakJava7(OJ7) syntax.
Organized code into Box and BoxTester classes.
Used ArrayList properly with add, remove, indexOf, and get methods
Used OakJava7 Collection for merging two output values
Here we have used OakJava7 collection to insert arraylist at java7 collection memory. The statement
for this is given below....
Java7Collection.InsertQUERY(x.ToString());
Here we have used OakJava7 collection to merge the output display23.java7.exe output with arraylist.The statement for this is given below....
Java7Collection.QUERY(x.ToString(),"display23");
This is one of Advanced concept in OakJava7(JAVA7.0).
The given output indicates that it is merging two DotWeb5.0 output by using Java7collection.
🖨️ Output
Volume of Box1 :210
Initial size is 0
The list is empty
List size is 4
The list is [1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [2000], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]
Java 5
HELLO WORLD! MY First DotWeb5.0 Program-display-program-1
The index of 4 is 2
3 not found
Element at 0 is 1
Element at 3 is 6
[[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [[1, [2000], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]], 4, 6]] removed
The list is [1, 4, 6]
6 removed
The list is [1, 4]
The list is not empty
List size is 2
✨ UNIT‑3 : DotWeb5.0 Advanced Concepts
(DotWeb5.0 util packages)
📖 Introduction
DotWeb5.0 Advanced Concepts were invented by Wilmix Jemin J.
They are part of the DotWeb5.0 Programming Language, with file extension .web7.
🪣 Bucket
Purpose: Store key–value data and generate random numbers.
Supports datatypes such as string, object, etc.
Syntax:
Bucket list = Bucket(); list.KeyAdd(); list.add(); list.RandomAdd(); list.Display(list);
Advantages:
Retrieve values by position
Fast searching and insertion compared to other DTS
Random indexing supported (duplicate values get unique random keys)
Can store many values
🔗 Extend
Purpose: Provides multiple inheritance in (up to 100,000,000 classes).
Behaves like a Bucket but contains a list of classes.
Syntax:
EXTEND <> list11 = EXTEND <> (STRING); list.KeyAdd(); list.add(); list.RandomAdd(); list.Display(list);
Advantages:
Add many values
Indexing supported
Lists class and object values
Stateless
🚦 Pipe
Purpose: Maintains stateful behavior and supports data flow between classes.
Can add constructor values from multiple classes and display them.
Syntax:
Pipe <> list11 = Pipe <> (STRING); list.KeyAdd(); list.add(); list.RandomAdd(); list.Display(list);
👜 Bag
Extension of: LinkedHashMap
Performance: Faster than Dictionary
Syntax:
Bag object = new Bag(); object.put(key,value);
Functions:
getValues(key) → Get values for a key
get(key,loc) → Get value at index
containsValue(value) → Check if value exists
put(key,value) → Add key–value pair
remove(key,value) → Remove key–value pair
🌳 TreeList
Similar to Bucket but stores items in tree format.
Syntax:
TreeList list = new TreeList("BUCKETS"); list.KeyAdd(KEY); list.add(VALUE1); list.RandomAdd(RANDOMNO); list.DisplayO(list,0);
🎭 Mask
Extension of tree structure, supports left/right retrieval.
Syntax:
Mask m = new Mask(); m.add(multiple values); m.getR(loc); // right position m.getL(loc); // left position
🏔 Heap
Creates a balanced tree, inserts data, and displays via inorder traversal.
Syntax:
Heap hob = new Heap(); hob.add(datum); hob = new Heap(key,value1,value2);
🪣 Bucktist
Similar to Bucket but stores two values per key.
Syntax:
Bucktist l = new Bucktist(key,value1,value2);
🏏 Wicket
Stores multiple values with four values per key.
Syntax:
Wicket list12 = new Wicket(key,v1,v2,v3,v4); list12.Display(); list12.Display(list12,location);
💻 Example Programs
Example 1: Bag
<WEB7>
<PACK> MyP
<%
<CLASS> Programs
{
public void main()
{
Bag b <NEW> Bag();
b.PUT(1,34);
b.PUT(2,444);
<PRINTLN>(""+b);
}
}
%>
?>
Example 2: CDOLLARARRAYS
<WEB7>
<USE> CUTIL;
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
ArrayList ar <NEW> ArrayList ();
for (int i=0;i<=100;i++)
ar.add(i,i);
<CDOLLARARRAYS> list1 <NEW> <CDOLLARARRAYS>("ANIMALS ");
list1.add("1 horse");
list1.add("2 pig");
list1.add("3 cow");
list1.add("4 goat");
list1.add("5 chicken");
list1.add("6 ostrich");
list1.add(ar.StringConvert());
for (int i=0;i<list1.size();i++)
<PRINTLN>(""+list1.get(i));
}
}
?>
Example 3: Bootloader
<WEB7>
<USE> CUTIL;
<PACK> MYOS
{
<CLASS> MYOs
{
public void main(){
<PRINTLN>("HelloWorld for booting MYOS");
}
}
?>
Example 4: Pointers
<WEB7>
<USE> CUTIL;
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
<Str> s="dsdds";
{*} l Pointers (s);
l.add(s);
for (int i = 0; i NOT= l.size(); i = i + 1)
{
<OBJECT> obj=l.GETKEY(i);
<PRINTLN>(obj);
}
}
}
?>
Example 5: Dictionary
<WEB7>
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
Dictionary<string, string> openWith <NEW> Dictionary<string, string>();
openWith.Add("txt", "notepad.exe");
openWith.Add("bmp", "paint.exe");
openWith.Add("dib", "paint.exe");
openWith.Add("rtf", "wordpad.exe");
}
}
?>
Example 6: Extend
<WEB7>
<USE> CUTIL;
<IMPORT>
<PACK> MyP
<%
<CLASS> Programs
<%
public void main()
{
EXTEND list <NEW> EXTEND("BUCKETS");
list.KeyAdd("1101");
list.add("jemin");
list.RandomAdd();
list.Display(list);
<PRINTLN>(""+list.DisplayO(list,1));
}
%>
?>
Example 7: Heap
<WEB7>
<USE> CUTIL;
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
Heap root <NEW> Heap("wilmix");
for (int i=0;i<=10;i=i+1)
root.add("item " + i);
<PRINTLN>(root.size());
root.printTree();
}
}
}
?>
Example 8: LArray
<WEB7>
<USE> CUTIL;
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
LArray root <NEW> LArray("root");
ArrayList ar <NEW> ArrayList();
for (int i=0;i<=1000;i++)
ar.add(i,i);
root.add("wilmix");
root.add("jemin");
root.add("shalom");
root.add("1010");
root.add("101");
root.add("201");
root.add(ar.StringConvert());
root.add("100000000");
root.printTree();
}
}
}
?>
Example 9: Pipe
<WEB7>
<USE> CUTIL;
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
Pipe list <NEW> Pipe("BUCKETS");
list.KeyAdd("1101");
list.add("jemin");
list.RandomAdd();
list.Display(list);
<PRINTLN>(""+list.DisplayO(list,1));
}
}
}
?>
Example 10: TreeList
<WEB7>
<USE> CUTIL;
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
TreeList list <NEW> TreeList("BUCKETS");
list.KeyAdd("1101");
list.add("jemin");
list.RandomAdd("1111");
TreeList list2 <NEW> TreeList("BUCKETS");
list2.KeyAdd("1102");
list2.add("rahul");
list2.RandomAdd("1112");
<PRINTLN>("DATA="+list.DisplayO(list,0));
<PRINTLN>("DATA="+list2.DisplayO(list2,0));
}
}
}
?>
🔹 Example‑11 : MASK
Purpose: Demonstrates the use of the MASK structure to add values and print a tree.
<WEB7>
<USE> CUTIL;
<PACK> My
{
<CLASS> Programs
{
public void main()
{
MASK root <NEW> MASK("wilmix");
for (int i = 0; i NOT= 10; i = i + 1)
{
root.add("item " + i);
}
root <NEW> MASK("root1",1211211,54441);
root <NEW> MASK("root2",121121,5444);
root <NEW> MASK("root5",99121888,"5");
root <NEW> MASK("root3",12112,544);
root <NEW> MASK("root4",1211,54);
root <NEW> MASK("root51",121,5);
root.printTree();
}
}
%>
?>
🔹 Example‑12 : WICKET
Purpose: Shows how to store multiple values per key using Wicket.
<WEB7>
<USE> CUTIL;
<PACK> MyPo
{
<CLASS> Programs
{
public void main()
{
Wicket list12;
list12 <NEW> Wicket(1000,10002,43433,4343,5555451);
list12 <NEW> Wicket(10001,100021,434331,4343,5555452);
list12 <NEW> Wicket(10002,100022,434332,4343,5555453);
list12 <NEW> Wicket(10003,100023,434333,4343,5555454);
list12 <NEW> Wicket(10004,100024,434334,4343,5555455);
list12 <NEW> Wicket(10005,100025,434335,4343,5555456);
list12.Display(list12);
<PRINTLN>("DATA="+list12.DisplayO(list12,0));
}
}
%>
?>
🔹 Example‑13 : STRUCTURE
Purpose: Demonstrates pointers and the STRUCTURE keyword to retrieve and display values.
<WEB7>
<USE> CUTIL;
<PACK> MyPoi
{
<CLASS> Programs
{
public void main()
{
<Str> s="dsdds";
{*} l Pointers(s);
l.add(s);
for (int i = 0; i NOT= l.size(); i = i + 1)
{
<OBJECT> obj=l.GETKEY(i);
<PRINTLN>(obj);
}
<STRUCTURE> list <NEW> <STRUCTURE>(l.GETKEY(0));
for (int i11 = 0; i11 NOT= list.size(); i11 = i11 + 1)
{
<OBJECT> el=list.ret(i11);
<PRINTLN>("SNO= "+el);
}
}
}
%>
?>
🔹 Example‑14 : BUCKETIST
Purpose: Illustrates the Bucketist structure, which allows storing two values per key.
<WEB7>
<USE> CUTIL;
<PACK> MyP
{
<CLASS> Programs
{
public void main()
{
Bucketist bp <NEW> Bucketist("wilmix");
bp <NEW> Bucketist(1,222,434);
bp <NEW> Bucketist(1,222,434);
bp.Display(bp);
<PRINTLN>("DATA="+bp.DisplayO(bp,1));
}
}
%>
?>
🌟 Final Notes
DotWeb5.0 Advanced Concepts extend the language with powerful data structures.
🌟 UNIT‑4 : DotWeb5.0 Advanced OOPS
📖 Introduction
DotWeb5.0 Advanced OOPS extends the language with powerful features such as:
Operator Overloading
Friend Functions
JDk‑Java OOPS
DotWeb5.0 OOPS
However, many Java developers are not aware of the advanced concepts introduced in DotWeb5.0.
📂 DotWeb5.0 FILEAPIs
DotWeb5.0 provides a rich set of File APIs for handling input/output operations:
JFile.display(String f1) → Displays file attributes
JFileInputStream.ReadBytes(String f1, int p) → Reads bytes from a file
JFileOutputStream.Write(String data, String f1, String f2, String f3, int r1, int r2) → Writes data bytes to a file
JFileReader.Read(String f1, int d) → Reads data from a file
JFileWriter.Write(String f1, char data[], String f2, String f3, String app, int r1, int r2) → Writes character data to a file
JInputStreamReader.ReadLN() → Reads a character from a file
JPrinter.call() → Enables printer functionality
JPrintWriter.display(String s1) → Writes a string
JSerialization.Serialize(String a, String s1, String s2) → Serializes and deserializes a string
JStreamTokenizer.Split(String f1) → Splits a string into tokens
💻 Program‑1 : oakweb1.java7
<JAVA7>
<CLASS> oakweb1
<%
void display()
<%
<PRINTLINE>("wilmix is going");
%>
%>
<CLASS> oakweb2
<%
<MAIN>
// it means it cannot be run in jdk1.8 compiler
<%
oakweb1 o <NEW> oakweb1();
<PRINTLINE>("Wilmix is going");
%>
</JAVA7>
// Note: This program cannot be run in JDK 1.8 compiler
⚙️ Compilation & Execution
To compile and run the program, use:
CoreJavac7 oakjava1.java7
🖥️ Output
Wilmix is going
==============================================================================================================
🌟 UNIT‑5 : DotWeb5.0 Programming Exercises
Welcome to the Dotweb5.0 (OJ7) practice set.
📘 Description: Print "HelloWorld" in the console.
💻 Code
// Basic Program for HelloWorld
<WEB>
<PACK> example
{
<CLASS> example1
{
public void main()
{
string input = Console.ReadLine();
<J7PRINT>(input);
}
}
}
🎯 Input / Output
Input
HelloWorld
Output
HelloWorld
📘 Description: Use if–else to check age and display category.
💻 Code
<WEB>
<PACK> example
{
<CLASS> example1
{
public void main()
{
<J7PRINT>("Enter your name :");
string name = Console.ReadLine();
<PRINTLN>("");
<J7PRINT>("Enter your Age :");
int age = int.Parse(Console.ReadLine());
<PRINTLN>("");
if ((age >= 0) && (age <= 9))
<PRINTLN>("Child is babby");
else if ((age >= 10) && (age <= 19))
<PRINTLN>("Child is boy");
else if ((age >= 20) && (age <= 29))
<PRINTLN>("Young Boy");
else if ((age >= 30) && (age <= 39))
<PRINTLN>("Man");
else if ((age >= 40) && (age <= 59))
<PRINTLN>("Medium Man");
else if (age >= 60)
<PRINTLN>("Old Man");
}
}
}
🎯 Input / Output
Input
Enter your name : Daniel
Enter your Age : 62
Output
Old Man
📘 Description: Check whether a number is positive or negative.
💻 Code
// Check if the given number is positive or negative
<WEB>
<PACK> testno
{
<CLASS> testno
{
public void main()
{
<J7PRINT>("Enter the Number :");
int no = int.Parse(Console.ReadLine());
<PRINTLN>("");
if (no < 0)
<PRINTLN>("The given number is Negative");
else if (no >= 0)
<PRINTLN>("The given number is Positive");
}
}
}
🎯 Input / Output
Input
Enter the Number : -1
Output
The given number is Negative
💻 Code
<WEB>
<PACK> mathpack
{
<CLASS> factorial
{
public void main()
{
<J7PRINT>("Enter the Number :");
int n = int.Parse(Console.ReadLine());
int fact = 1;
for (int i = 1; i <= n; i++)
{
fact = fact * i;
}
<PRINTLN>("Factorial of " + n + " is : " + fact);
}
}
}
🎯 Input / Output
Input
Enter the Number : 5
Output
Factorial of 5 is : 120
💻 Code
<WEB>
<PACK> stringpack
{
<CLASS> stringnum
{
public void main()
{
string text = "Weldone";
int number = 1345;
<PRINTLN>(text + " " + number);
}
}
}
🎯 Output
Weldone 1345
💻 Code
<WEB>
<PACK> numberpack
{
<CLASS> oddeven
{
public void main()
{
<J7PRINT>("Enter the Number :");
int no = int.Parse(Console.ReadLine());
if (no % 2 == 0)
<PRINTLN>("The given number is EVEN");
else
<PRINTLN>("The given number is ODD");
}
}
}
🎯 Input / Output
Input
Enter the Number : 7
Output
The given number is ODD
============================================================================================
Program (Dotweb5.0 style):
<WEB>
<PACK> testprime
{
<CLASS> prime
{
public void main()
{
<J7PRINT>("Enter the Number :");
int num = int.Parse(Console.ReadLine());
bool isPrime = true;
for (int i = 2; i <= num / 2; i++) {
if (num % i == 0) {
isPrime = false;
break;
}
}
if (isPrime && num > 1) {
<PRINTLN>(num + " is a Prime Number");
} else {
<PRINTLN>(num + " is NOT a Prime Number");
}
}
}
}
Sample Output:
Enter the Number : 7
7 is a Prime Number
Enter the Number : 10
10 is NOT a Prime Number
Program:
<WEB>
<PACK> rainbowcolors
{
<CLASS> vibgyor
{
public void main()
{
string [] colours = {"Red","Orange","Yellow","Green","Blue","Indigo","Violet"};
foreach (string colour in colours) {
<PRINTLN>("Colour: " + colour);
}
}
}
}
Sample Output:
Colour: Red
Colour: Orange
Colour: Yellow
Colour: Green
Colour: Blue
Colour: Indigo
Colour: Violet
Program:
<WEB>
<PACK> example
{
<CLASS> Counter
{
public void main()
{
int count = 1;
while (count <= 5) {
<PRINTLN>("Count is: " + count);
count++;
}
}
}
}
Sample Output:
Count is: 1
Count is: 2
Count is: 3
Count is: 4
Count is: 5
Program:
<WEB>
<PACK> employees
{
<CLASS> empcodes
{
public void main()
{
<J7PRINT>("Enter the Employee code :");
int empcode = int.Parse(Console.ReadLine());
switch (empcode) {
case 1:
<PRINTLN>("Junior Software Engineer");
break;
case 2:
<PRINTLN>("Senior Software Engineer");
break;
case 3:
<PRINTLN>("Developer Lead");
break;
case 4:
<PRINTLN>("Tech Lead");
break;
case 5:
<PRINTLN>("Team Lead");
break;
case 6:
<PRINTLN>("Software Architect");
break;
case 7:
<PRINTLN>("Project Manager");
break;
default:
<PRINTLN>("Invalid Employee Code");
break;
}
}
}
}
Sample Output:
Enter the Employee code : 3
Developer Lead
Enter the Employee code : 8
Invalid Employee Code
✨ Summary:
These examples demonstrate the four main control structures in Dotweb5.0:
For Loop → Prime number check
For-Each Loop → Rainbow colours
While Loop → Counter
Switch Case → Employee role lookup
================================================================================================
## 📌 what is Dotweb5.0 Structure ?
- Structures are declared using the **`struct`** keyword.
- They are similar to classes but are **stored on the stack** (value type).
- A structure can include:
- **Fields**
- **Methods**
- **Properties**
- **Constructors**
- Unlike classes, **structs cannot inherit** from another struct or class. However, they **can implement interfaces**.
- Best suited for **small data structures** that represent simple values such as coordinates, colors, or records.
## 🖥️ Example: DotWeb5.0 Structure
Webstructures.web
<WEB>
<PACK> geometry
{
<STRUCT> Point
{
public int X;
public int Y;
// Constructor
public Point(int x, int y)
{
X = x;
Y = y;
}
// Method: distance from origin
public double DistanceFromOrigin()
{
return Math.Sqrt((X * X) + (Y * Y));
}
// Static method: add two points
public Shared Point Add(Point a, Point b)
{
Point result <NEW> Point(0,0);
result.X = a.X + b.X;
result.Y = a.Y + b.Y;
return result;
}
public void Print()
{
<PRINTLN>("(" + X + "," + Y + ")");
}
}
<STRUCT> Rectangle
{
public Point TopLeft;
public int Width;
public int Height;
public Rectangle(Point topLeft, int width, int height)
{
TopLeft = topLeft;
Width = width;
Height = height;
}
public int Area()
{
return Width * Height;
}
public bool Contains(Point p)
{
return (p.X >= TopLeft.X) &&
(p.Y >= TopLeft.Y) &&
(p.X <= TopLeft.X + Width) &&
(p.Y <= TopLeft.Y + Height);
}
public void Print()
{
<PRINTLN>("Rect @ (" + TopLeft.X + "," + TopLeft.Y +
") w=" + Width + " h=" + Height);
}
}
<CLASS> Program
{
public void main()
{
Point p1 <NEW> Point(3,4);
Point p2 <NEW> Point(5,6);
Point p3 = Point.Add(p1,p2);
p1.Print();
<PRINTLN>("Dist=" + p1.DistanceFromOrigin());
p2.Print();
<PRINTLN>("Dist=" + p2.DistanceFromOrigin());
p3.Print();
Rectangle rect <NEW> Rectangle(p1,10,8);
rect.Print();
<PRINTLN>("Area=" + rect.Area());
<PRINTLN>("Contains p1? " + rect.Contains(p1));
<PRINTLN>("Contains (15,2)? " + rect.Contains(new Point(15,2)));
}
}
}
}
✨ Output (Console-like)
Point p1: (3,4)
Distance from origin: 5
Point p2: (5,6)
Distance from origin: 7.81024967590665
Point p3 (p1 + p2): (8,10)
Rectangle: Rect @ (3,4) w=10 h=8
Area: 80
Contains p1? True
Contains (15,2)? False
## 🧩 What the Program Does
Your program defines **two structures** (`Point` and `Rectangle`) and a **main class** (`Program`) that demonstrates how they work.
### 1. **Point Structure**
- **Fields:** `X` and `Y` (represent coordinates).
- **Constructor:** Initializes a point with given `x` and `y` values.
- **Method:** `DistanceFromOrigin()` calculates how far the point is from `(0,0)` using the distance formula.
- **Static Method:** `Add(Point a, Point b)` creates a new point by adding the coordinates of two points.
- **Print Method:** Displays the point in `(X,Y)` format.
👉 This structure models a simple 2D point.
---
### 2. **Rectangle Structure**
- **Fields:** `TopLeft` (a `Point`), `Width`, and `Height`.
- **Constructor:** Initializes a rectangle with position and size.
- **Method:** `Area()` calculates the rectangle’s area.
- **Method:** `Contains(Point p)` checks if a given point lies inside the rectangle.
- **Print Method:** Displays rectangle details (position, width, height).
👉 This structure models a rectangle in 2D space.
---
### 3. **Program Class**
- The `main()` method demonstrates usage:
- Creates points (`p1`, `p2`, `p3`).
- Prints their coordinates and distances from origin.
- Creates a rectangle and prints its details.
- Checks if certain points are inside the rectangle.
🔑 Highlights
p1 and p2 are individual points with their distances calculated.
p3 is the sum of p1 and p2.
The rectangle is defined at (3,4) with width 10 and height 8.
The program checks whether points lie inside the rectangle.
## ✨ Key Takeaways
- **DotWeb5.0 structures** are similar to C# structs: lightweight, stack-based, and good for simple data models.
- The program shows **object creation (`<NEW>`), printing (`<PRINTLN>`), and methods** in action.
- It demonstrates **encapsulation**: grouping related data (coordinates, rectangle dimensions) with behaviors (distance, area, contains).
## ✨ Why Use Structures?
- **Logical organization**: Keep related data together instead of scattering variables.
- **Encapsulation**: Bundle information into a single unit for clarity.
- **Readability & maintainability**: Code becomes easier to understand and manage.
- **Efficiency**: Ideal for lightweight data models that don’t require inheritance.
Note:
Dotweb5.0 contains Advanced Structures, which are better than Structure Type‑1.
dotwebwithStructure.web
<WEB>
<PACK> dotwebsample
{
<CLASS> example1
{
public void main()
{
<PRINTLN>("*************************************************************************");
<PRINTLN>("J7Structure in Dotweb 5.0 is powerful, and it can store more records than any other structure.");
<PRINTLN>("J7Structure in Dotweb 5.0");
// Create a Structure named 'liste'
CLIB.Structure liste <NEW> CLIB.Structure("Strutdatas");
// Add 10 data elements to the structure
for (int i11 = 0; i11 < 10; i11 = i11 + 1)
{
liste.add("data" + i11);
}
// Retrieve and print all elements from the structure
for (int i11 = 0; i11 < liste.size(); i11 = i11 + 1)
{
Object el = liste.ret(i11);
<PRINTLN>("SNO = " + el);
}
// Remove the 5th element
liste.Remove(5);
<PRINTLN>(liste);
// Remove all elements
liste = CLIB.Structure.RemoveAll(liste);
<PRINTLN>(liste);
// Check if the structure is empty
<PRINTLN>(CLIB.Structure.isEmpty(liste));
}
}
}
J7Structure in Dotweb 5.0 is a powerful data structure capable of storing more records than traditional structures.
A structure in Dotweb 5.0 is created using the following syntax:
CLIB.Structure structobj <NEW> CLIB.Structure(initialValue);
*************************************************************************
J7Structure in Dotweb 5.0 is powerful, and it can store more records than any other structure.
J7Structure in Dotweb 5.0
SNO = Strutdatas
SNO = data0
SNO = data1
SNO = data2
SNO = data3
SNO = data4
SNO = data5
SNO = data6
SNO = data7
SNO = data8
SNO = data9
CLIB.Structure@189441b
True
✅ Initialization: A structure is created with an initial value.
✅ Data Insertion: Multiple records can be added dynamically.
✅ Data Retrieval: Elements can be accessed using index-based retrieval.
✅ Modification: Specific elements can be removed.
✅ Cleanup: All elements can be cleared at once.
✅ Validation: The structure provides a method to check if it is empty.
Note: For DOTWEB5.0 Programming Language ENLIGHT IDE is used , it is beautiful , easy to use developed by Wilmix jemin J.
You can see the screenshot for the J7Structure for your reference...
Heap Data Structure
Heap data structures play an important role in securing data.
Heap data structures display values in a tree format.
Syntax for Heap Data Structure
CLIB.Heap = new CLIB.Heap("Heap"); .add(data);
Example
Heapsample.web
<WEB>
<PACK> Javadtspart5
{
<CLASS> J7Heap
{
public void main() {
<PRINTLN>("HEAP in Java7.0");
<PRINTLN>("==================");
CLIB.Heap h <NEW> CLIB.Heap("Heap");
CUTIL.ArrayList ar1 <NEW> CUTIL.ArrayList();
for (int i=0;i<10;i++)
ar1.add(i,i+3);
h.add("wilmix1");
h.add("wilmix2");
h.add("wilmix3");
h.add("wilmix4");
h.add("wilmix5");
h.add(ar1);
CUTIL.ArrayList ar=h.get();
<PRINTLN>( h);
<PRINTLN>( ar);
}
}
}
Explanation
CLIB.Heap h = new CLIB.Heap("Heap"); h.add("wilmix1"); h.add("wilmix2"); h.add("wilmix3"); h.add("wilmix4"); h.add("wilmix5");
Here we initialize the heap with the name "Heap".
We then add the values wilmix1, wilmix2, wilmix3, wilmix4, wilmix5 to the heap.
When we print the heap object h, the original values are not displayed.
Instead, the output shows something like:
CLIB.Heap@189441b
To convert the heap values into a readable format, we use CUTIL.ArrayList:
CUTIL.ArrayList ar = h.get();
Using Dotweb3.0 / OakJava7 ArrayList
CUTIL.ArrayList ar1 = new CUTIL.ArrayList();
for (int i = 0; i < 10; i++)
{
ar1.add(i, i + 3);
}
When you add this ArrayList to the heap:
h.add(ar1);
and print the heap:
<PRINTLN>(h);
The output will still look like:
CLIB.Heap@189441b
But when you call h.get(), the output is:
[[3, 4, 5, 6, 7, 8, 9, 10, 11, 12], wilmix5, wilmix4, wilmix3, wilmix2, wilmix1]
Final Combined Output
HEAP in Java 7.0
==================
CLIB.Heap@189441b
[[3, 4, 5, 6, 7, 8, 9, 10, 11, 12], wilmix5, wilmix4, wilmix3, wilmix2, wilmix1]
Notes
You must include the J7LIB.dll file in the project properties.
This process generates an obfuscated file format (Heapsample.jclass) that cannot be reverse engineered or converted back to the real source code of Dotweb5.0 or OakJava7.
The advantage is that if you already know C# or Java, learning this system is straightforward. That is why Dotweb5.0 / OakJava7 (Java 7.0) is considered more secure than other programming languages.
======================================================================================================
🖨️ Output
LinkedList
📖 Definition
A linked list is a linear data structure in which elements, called nodes, are connected using pointers. Each node contains two parts:
• Data: the actual value stored.
• Reference (or pointer): a link to the next node in the sequence.
Unlike arrays, linked lists do not store elements in contiguous memory locations. Instead, nodes are scattered in memory and connected through references.
🔑 Key Characteristics
• Dynamic size: Can grow or shrink at runtime without reallocating memory.
• Efficient insertion/deletion: Adding or removing nodes is faster compared to arrays, especially in the middle of the list.
• Sequential access: Elements must be traversed one by one; random access is not possible.
I believe everyone is familiar with the concept of a linked list. It is important to understand the fundamentals of this data structure and how to implement it using the modern language Dotweb5.0.
LinkedSample.web
<WEB>
<PACK> Dotweb5Oj7dts
{
<CLASS> LinkedList
{
public void main() {
<PRINTLN>("===============================");
<PRINTLN>("LinkedList in Dotweb5.0 / Java7.0");
CLIB.LinkedList ll = new CLIB.LinkedList();
ll.add("1011L");
ll.add("1013L");
ll.addFirst("10L");
ll.addLast("20L");
ll.addLast("30L");
ll.addAtPosition(1, "15L"); // Insert 15 at index 1
<PRINTLN>("List after additions:");
ll.display();
ll.removeFirst();//remove Ist element
// remove() method will remove
// the head of the LinkedList
ll.remove();
<PRINTLN>("After removing first:");
ll.display();
ll.removeLast(); // Remove the Last element
<PRINTLN>("After removing last:");
ll.display();
<PRINTLN>("===============================");
}
}
}
===============================
LinkedList in Dotweb5.0 / Java7.0
List after additions:
10L -> 15L -> 1013L -> 1011L -> 20L -> 30L -> null
After removing firstElement:
1013L -> 1011L -> 20L -> 30L -> null
After removing lastElement:
1013L -> 1011L -> 20L -> null
===============================
===========================================================================================
Bag Data Structure
The Bag Data Structure is used to create a hierarchical tree-like structure.
For example, Peter is working as a software engineer at Company ABC. From his CEO, S. Andrew, down to Peter, there are 10 lead members in the hierarchy.
To represent such a hierarchy in a tree-like format, you can use the Bag Data Structure. While a traditional tree data structure can be complex, the Bag Data Structure provides a simpler way to achieve the same result.
Example
<WEB>
<PACK> Javadtspart5
{
<CLASS> J7Bag
{
public void main() {
<PRINTLN>("Bag in Java7.0 / Dotweb5.0");
Bag tree <NEW> Bag();
Bag Member <NEW> Bag();
Member.PUT("A","CLASS5");
Member.PUT("B","CLASS5");
Member.PUT("C","CLASS5");
Member.PUT("D","CLASS5");
Member.PUT("CLASS6","CLASS6");
Bag slibings <NEW> Bag();
slibings.PUT("A","s1");
slibings.PUT("A","s2");
slibings.PUT("B","s11");
slibings.PUT("B","s21");
slibings.PUT("C","s12");
slibings.PUT("C","s22");
Bag activity <NEW> Bag();
activity.PUT("s1","cricket");
activity.PUT("s2","read");
activity.PUT("s21","swim");
activity.PUT("s12","swim");
tree.PUT(1,Member);
tree.PUT(2,slibings);
tree.PUT(3,activity);
activity.remove("s1","cricket");
tree.remove(3,activity);
tree.PUT(3,activity);
<PRINTLN>("output="+tree.containsValue(Member));
<PRINTLN>("outputTree="+tree);
<PRINTLN>("===============================");
}
}
}
Explanation
Root Creation
Bag tree Bag();
This creates the root of the tree.
Child Members
Bag Member Bag(); Member.PUT("A","CLASS5"); Member.PUT("B","CLASS5"); Member.PUT("C","CLASS5"); Member.PUT("D","CLASS5"); Member.PUT("CLASS6","CLASS6"); Here, A, B, C, and D belong to CLASS5. CLASS6 has only one member.
Siblings
Bag siblings Bag(); siblings.PUT("A","s1"); siblings.PUT("A","s2"); siblings.PUT("B","s11"); siblings.PUT("B","s21"); siblings.PUT("C","s12"); siblings.PUT("C","s22");
A has siblings s1 and s2.
B has siblings s11 and s21.
C has siblings s12 and s22.
Activities
activity.PUT("s1","cricket"); activity.PUT("s2","read"); activity.PUT("s21","swim"); activity.PUT("s12","swim"); Each sibling is associated with an activity.
Hierarchy Assembly
tree.PUT(1, Member); tree.PUT(2, siblings); tree.PUT(3, activity); Members, siblings, and activities are added to the root tree.
Updating Activities
activity.remove("s1","cricket"); tree.remove(3, activity); tree.PUT(3, activity); For example, s1 stops playing cricket in 2005 and rejoins in 2025.
Validation and Output
<PRINTLN>("output=" + tree.containsValue(Member)); <PRINTLN>("outputTree=" + tree);
Checks if Member is a child of the root tree.
Prints the entire tree hierarchy.
==============================================================================
=============================================================================================================
MATH SIN@ and COS@ Operations and J7ARRAYS Datastructures
=============================================================================================================
J7ARRAYS Data Structures
This type of data structure is used to store items such as ArrayList and Structure types. It is capable of holding a large number of values compared to traditional arrays in most programming languages.
Write a DotWeb5.0 program that performs the following tasks:
Calculate and display the sine and cosine values of the number 10.
Create an ArrayList and add several elements to it.
Insert the ArrayList into a data structure.
Print the elements of in ascending order.
Print the elements of in descending order.
MathandJ7Arrays.web
<WEB>
<PACK> Program8
{
<CLASS> Prog
{
public void main()
{
<PRINTLN>("===============================");
// Use Math functions to find the Cosine and Sine values
<PRINTLN>("Sin value = " + Math.Sin(10));
<PRINTLN>("Cos value = " + Math.Cos(10));
<PRINTLN>("===============================");
// Create an ArrayList and add elements
CUTIL.ArrayList ar = new CUTIL.ArrayList();
ar.add(0, "wilmix1");
ar.add(1, "wilmix2");
ar.add(2, "wilmix3");
ar.add(3, "wilmix4");
ar.add(4, "wilmix5");
<PRINTLN>("J7ARRAYS in Java7.0");
// Create a J7ARRAYS object
<J7ARRAYS> u = new <J7ARRAYS>("Wilmix");
// Add integers and ArrayList elements to J7ARRAYS
for (int i = 100; i > 0; i--)
{
u.add("" + i); // Add integers
u.add("" + ar.ToString()); // Add ArrayList as string
}
// Retrieve specific elements
<PRINTLN>("Value at position 5 = " + u.ret(5));
<PRINTLN>("Value at position 11 = " + u.ret(11));
<PRINTLN>("Value at position 45 = " + u.ret(45));
// Sort in Ascending order and print
u.ASCENDSORT();
<PRINTLN>("Ascending Order: " + u.RET());
// Sort in Descending order and print
u.DESCENDSORT();
<PRINTLN>("Descending Order: " + u.RET());
<PRINTLN>("===============================");
}
}
}
🔎 Step-by-Step Explanation
Program Start
Prints a separator line (===============================) to mark the beginning.
Math Functions
Uses Math.Sin(10) to calculate the sine of 10.
Uses Math.Cos(10) to calculate the cosine of 10.
Prints both results.
ArrayList Creation
Creates a CUTIL.ArrayList named ar.
Adds five string elements: "wilmix1", "wilmix2", "wilmix3", "wilmix4", "wilmix5".
J7ARRAYS Initialization
Creates a J7ARRAYS object u with the initial value "Wilmix".
Runs a loop from 100 down to 1:
Adds each integer (converted to string) into u.
Also adds the ArrayList contents as a string.
Element Retrieval
Retrieves and prints the element at position 5.
Retrieves and prints the element at position 11.
Retrieves and prints the element at position 45.
Sorting Demonstration
Sorts the J7ARRAYS in ascending order using ASCENDSORT().
Prints all values in ascending order with RET().
Sorts the J7ARRAYS in descending order using DESCENDSORT().
Prints all values in descending order with RET().
Program End
Prints another separator line (===============================) to mark the end.
👉 In short, this program shows math operations (sin & cos), array handling, element retrieval, and sorting in DotWeb5.0.
===============================
Sin value = -0.54402111088937
Cos value = -0.839071529076452
===============================
J7ARRAYS in Java7.0
Value=96
Value=90
56
[1, 10, 100, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 5, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 6, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 7, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 8, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 9, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, [wilmix1, wilmix2, wilmix3, wilmix4, wilmix5]]
[[wilmix1, wilmix2, wilmix3, wilmix4, wilmix5], 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 9, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 8, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 7, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 6, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 5, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 4, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 3, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 2, 19, 18, 17, 16, 15, 14, 13, 12, 11, 100, 10, 1]
===============================
===============================================================================================================
Mask DataStructure with ArrayList
===============================================================================================================
# 📘 Mask Data Structure
---
## 1️⃣ Introduction
The **Mask Data Structure (Mask DTS)** is a **tree-based data structure** that also supports integration with **ArrayLists** and other structural elements.
- It **preserves insertion order**.
- Each Mask DTS instance consists of **two keys**:
- **Primary Key** → the main identifier.
- **Random Key** → an auxiliary identifier.
- After defining keys, you can pass **integers, strings, or any data type** into the structure.
---
## 2️⃣ Example Usage
Write a dotweb5.0 program to create two array lists and add 10 datas to mask dts and add
3 set of values and Mask dts will print in tree format automatically.
Consider the following example:
Maskexample.web
===============
<WEB>
<PACK> Makexample
{
public <CLASS> Makdts
{
public void main()
{
<PRINTLN>("===============================");
<PRINTLN>("MASK in Java7.0");
CLIB.MASK root <NEW> CLIB.MASK("root1");
CLIB.MASK root1 <NEW> CLIB.MASK("root2");
// Add 10 datas to the ArrayList
CUTIL.ArrayList ar1 <NEW> CUTIL.ArrayList();
for (int i=0;i<10;i++)
ar1.add(i,i+3);
// Add 10 datas to the ArrayList
CUTIL.ArrayList ar11 <NEW> CUTIL.ArrayList();
for (int i=0;i<10;i++)
ar11.add(i,i+5);
root.add("TreeA");
root1.add("TreeB");
//print the tree's size
<PRINTLN>(root.size() );
//print the tree's size
<PRINTLN>(root1.size() );
//Here string root1 is the key and 45678 is the data and ar1 contains Arraylist data
root <NEW> CLIB.MASK("root1",ar1,45678);
root <NEW> CLIB.MASK("root2",ar11,45679);
root <NEW> CLIB.MASK("root5",99121888,"5");
root1 <NEW> CLIB.MASK("root3",12112,544);
root1 <NEW> CLIB.MASK("root4",1211,54);
root1 <NEW> CLIB.MASK("root51",121,5);
<PRINTLN>("===============================");
}
}
}
Note:
```java
root <NEW> CLIB.MASK("root1", ar1, 45678);
```
- Here, `"root1"` is the **primary key**.
- `45678` is the **data value**.
- `ar1` contains **ArrayList data**.
This demonstrates that multiple sets of values can be added to the Mask Data Structure.
When values are added using the same instance (`root` or `root1`), the structure returns a **tree-format data type** as output.
## 3️⃣ Output Behavior
The Mask DTS prints input values in **tree format** while maintaining **insertion order**.
---
## 4️⃣ Sample Output (Java 7.0)
```text
MASK in Java7.0
2
2
[-8526742942261834865->
-8526742942261834865->
-8526742942261834865]
[root1->
root1->
root1]
[-8526742942261834865->
45678->
[[3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]
[2460193834502673226->
2460193834502673226->
2460193834502673226]
[root2->
root2->
root2]
[2460193834502673226->
45679->
[[5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]]
[4202369142879245978->
4202369142879245978->
4202369142879245978]
[root5->
root5->
root5]
[4202369142879245978->
5->
[99121888]]
[6731882546062678810->
6731882546062678810->
6731882546062678810]
[root3->
root3->
root3]
[6731882546062678810->
544->
[12112]]
[3854722413359444045->
3854722413359444045->
3854722413359444045]
[root4->
root4->
root4]
[3854722413359444045->
54->
[1211]]
[-660321338655634768->
-660321338655634768->
-660321338655634768]
[root51->
root51->
root51]
[-660321338655634768->
5->
[121]]
```
---
## 5️⃣ Key Takeaways
- ✅ **Tree-based structure** with insertion order preserved.
- ✅ Supports **multiple data types** (Integer, String, ArrayList, etc.).
- ✅ Each entry is defined by **two keys** (Primary + Random).
- ✅ Output is always in **tree format**.
---
# 🌳 Mask Data Structure — Tree Representation
```
MaskDTS (Root)
│
├── root1 (Primary Key)
│ ├── RandomKey: -8526742942261834865
│ ├── Value: 45678
│ └── ArrayList: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
│
├── root2 (Primary Key)
│ ├── RandomKey: 2460193834502673226
│ ├── Value: 45679
│ └── ArrayList: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
│
├── root5 (Primary Key)
│ ├── RandomKey: 4202369142879245978
│ ├── Value: 5
│ └── ArrayList: [99121888]
│
├── root3 (Primary Key)
│ ├── RandomKey: 6731882546062678810
│ ├── Value: 544
│ └── ArrayList: [12112]
│
├── root4 (Primary Key)
│ ├── RandomKey: 3854722413359444045
│ ├── Value: 54
│ └── ArrayList: [1211]
│
└── root51 (Primary Key)
├── RandomKey: -660321338655634768
├── Value: 5
└── ArrayList: [121]
```
---
## 🔑 How to Read This Diagram
- **Primary Key (rootX)** → The main identifier for each node.
- **Random Key** → A unique secondary identifier.
- **Value** → An integer or string associated with the node.
- **ArrayList** → A collection of values stored under the node.
---
## 📌 Professional Notes
- This structure is **hierarchical** and **ordered by insertion**.
- Each node can hold **multiple data types**.
- The **tree format output** makes traversal and visualization straightforward.
============================================================================================================
PIPE Datastructure With CLASS
=============================================================================================================
Maintains stateful behavior.
Supports data flow between classes.
Can add constructor values, method values, or object values from multiple classes and display them.
Pipe<> list = Pipe<>(STRING);
list.KeyAdd();
list.add();
list.RandomAdd();
list.Display(list);
<WEB>
<PACK> pipesn
{
public <CLASS> PipeA {
public string getValues() {
<PRINTLN>("I am PIPE A");
return "Positive";
}
}
public <CLASS> PipeC : PipeA {
public string getValues() {
<PRINTLN>("I am PIPE C");
return "Negative";
}
}
public <CLASS> PipeB {
public string getValues() {
<PRINTLN>("I am PIPE B");
return "Medium";
}
}
public <CLASS> Pipefinal {
public void main() {
<PRINTLN>("PIPE in Java7.0");
Pipe pipe <NEW> Pipe("BUCKETS");
PipeA pipes1 <NEW> PipeC();
PipeB pipes2 <NEW> PipeB();
pipe.KeyAdd("1101");
pipe.add(pipes1);
pipe.RandomAdd();
pipe.Display(pipe);
<PRINTLN>("" + pipe.DisplayO(pipe,0));
Pipe pipe1 <NEW> Pipe("BUCKETS1");
pipe1.KeyAdd("1102");
pipe1.add(pipes2);
pipe1.RandomAdd();
pipe1.Display(pipe1);
<PRINTLN>("" + pipe1.DisplayO(pipe1,1));
Pipe pipe2 <NEW> Pipe("BUCKETS of Pipe");
pipe2.KeyAdd("129089");
pipe2.add(pipes1.getValues());
pipe2.add(pipes2.getValues());
pipe2.RandomAdd();
pipe2.Display(pipe2);
<PRINTLN>("" + pipe2.DisplayO(pipe2,1));
}
}
}
pipe.KeyAdd("1101"); → Adds key 1101.
pipe.add(pipes1); → Adds object pipes1.
pipe.RandomAdd(); → Adds a random number manually.
pipe.Display(pipe); → Displays the pipe values.
pipe.DisplayO(pipe,0); → Displays the value at location 0.
👉 Note:
PipeA pipes1 <NEW> PipeC(); means PipeC inherits from PipeA.
The getValues() method is overridden in PipeC.
When invoked, it executes the child class method (PipeC) instead of the parent (PipeA).
📐 UML Class Diagram (Text Representation)
┌───────────────────────┐
│ PipeA │
├───────────────────────┤
│ + getValues(): string │
└───────────▲───────────┘
│ (inherits)
│
┌───────────────────────┐
│ PipeC │
├───────────────────────┤
│ + getValues(): string │
└───────────────────────┘
┌───────────────────────┐
│ PipeB │
├───────────────────────┤
│ + getValues(): string │
└───────────────────────┘
┌─────────────────────────────┐
│ Pipefinal │
├─────────────────────────────┤
│ + main(): void │
└───────────┬────────────────┘
│ uses
│
┌───────────────────┼───────────────────┐
│ │ │
┌────▼─────┐ ┌────▼─────┐ ┌────▼─────┐
│ Pipe │ │ PipeA │ │ PipeB │
│ (object) │ │ / PipeC │ │ │
└──────────┘ └──────────┘ └──────────┘
🔹 Explanation
• PipeA: Base class with returning .
• PipeC: Inherits from , overrides returning .
• PipeB: Independent class with returning .
• Pipefinal: Contains method. Creates objects and uses and .
✨ This diagram shows both inheritance (PipeC → PipeA) and usage relationships (Pipefinal uses Pipe, PipeA/PipeC, PipeB).
PIPE in Java7.0
[8929290914726757639->8929290914726757639->8929290914726757639]
[BUCKETS->BUCKETS->BUCKETS]
[1101->1101->pipesn.PipeC]
[BUCKETS->BUCKETS->BUCKETS]
[1101->1101->pipesn.PipeC]
[BUCKETS->BUCKETS->BUCKETS]
[4381897666345927633->4381897666345927633->4381897666345927633]
[BUCKETS1->BUCKETS1->BUCKETS1]
[1102->1102->pipesn.PipeB]
[BUCKETS1->BUCKETS1->BUCKETS1]
[1102->1102->pipesn.PipeB]
[1102->pipesn.PipeB->1102]
[4287233612369726592->4287233612369726592->4287233612369726592]
I am PIPE A
I am PIPE B
[BUCKETS of Pipe->BUCKETS of Pipe->BUCKETS of Pipe]
[129089->129089->Positive]
[BUCKETS of Pipe->BUCKETS of Pipe->BUCKETS of Pipe]
[129089->129089->Positive]
[129089->Positive->129089]
Pipe acts like a container that can hold keys, objects, and values.
Inheritance works as expected: child class overrides parent’s method.
RandomAdd introduces variability in stored values.
Display & DisplayO provide structured output and indexed retrieval.
===========================================================================================================
EXTEND DATASTRUCTURE
======================================================================================
📘 EXTEND Datastructure
🔹 Overview
Extend behaves like Encapsulation in Java/.Net.
Supports Add and Read operations (❌ Delete not allowed).
Provides multiple inheritance (up to 100,000,000 classes).
Functions like a Bucket containing classes with methods and values.
Uses super key for values of any type.
String values can be used as Table Headers.
Allows adding class objects and random keys.
🔹 Example Behavior
Adding A1, A2 class objects produces:
Exdexample.extendprog1+A1 Exdexample.extendprog1+A2 Instantiating class A15 and calling A15Print() prints:
Iam a Young fellow
and returns:
Iam Age A15
Write a Dotweb5.0 Program using Extend datastructure add Randomkey,Values,15 Class with 15 methods and class objects.
⚙️ Program: Extendexample.web
<WEB>
<PACK> Exdexample
{
<CLASS> extendprog1
{
public void main()
{
<PRINTLN>("===============================");
<PRINTLN>("EXTEND in Java7.0");
CLIB.EXTEND list <NEW> CLIB.EXTEND("jem");
list.KeyAdd("1101");
list.add("SNO,");
list.add("SchoolName,");
list.add("StudentName,");
list.add("Section A,");
list.add("Subject1,");
list.add("Subject2,");
list.add("Subject3,");
list.add("Subject4,");
list.add("Subject5,");
list.add("TotalMark,");
list.add("Status,");
list.add("GRADE");
list.RandomAdd();
<PRINTLN>("*************************************************************************");
list.add("[");
list.add("1,");
list.add("EDWillMottSchool,");
list.add("Andrew,");
list.add("A1,");
list.add("75,");
list.add("75,");
list.add("75,");
list.add("75,");
list.add("75,");
list.add("375,");
list.add("Distinction,");
list.add("B");
list.add("]");
list.RandomAdd();
list.KeyAdd("Schools");
list.add(new A1());
list.add(new A2());
list.add(new A3());
list.add(new A4());
list.add(new A5());
list.add(new A6());
list.add(new A7());
list.add(new A8());
list.add(new A9());
list.add(new A10());
list.add(new A11());
list.add(new A12());
list.add(new A13());
list.add(new A14());
A15 a15 <NEW> A15();
list.add(a15.A15Print());
<PRINTLN>("For Extend we can store and retrieve the data , but can't delete it");
<PRINTLN>("*************************************************************************");
for(int i=0;i<list.sizefordata();i++)
<PRINTLN>(""+ list.getVal(i));
<PRINTLN>("*************************************************************************");
}
// 15 classes and 15 methods
public <CLASS> A1
{
public void A1Print()
{
<PRINTLN>("Iam A1");
}
}
public <CLASS> A2
{
public void A2Print()
{
<PRINTLN>("Iam A2");
}
}
public <CLASS> A3
{
public void A3Print()
{
<PRINTLN>("Iam A3");
}
}
public <CLASS> A4
{
public void A4Print()
{
<PRINTLN>("Iam A4");
}
}
public <CLASS> A5
{
public void A5Print()
{
<PRINTLN>("Iam A5");
}
}
public <CLASS> A6
{
public void A6Print()
{
<PRINTLN>("Iam A6");
}
}
public <CLASS> A7
{
public void A7Print()
{
<PRINTLN>("Iam A7");
}
}
public <CLASS> A8
{
public void A8Print()
{
<PRINTLN>("Iam A8");
}
}
public <CLASS> A9
{
public void A9Print()
{
<PRINTLN>("Iam A9");
}
}
public <CLASS> A10
{
public void A10Print()
{
<PRINTLN>("Iam A10");
}
}
public <CLASS> A11
{
public void A11Print()
{
<PRINTLN>("Iam A11");
}
}
public <CLASS> A12
{
public void A12Print()
{
<PRINTLN>("Iam A12");
}
}
public <CLASS> A13
{
public void A13Print()
{
<PRINTLN>("Iam A13");
}
}
public <CLASS> A14
{
public void A14Print()
{
<PRINTLN>("Iam A14");
}
}
public <CLASS> A15
{
public string A15Print()
{
<PRINTLN>("Iam a Young fellow");
return("Iam Age A15");
}
}
}
}
┌───────────────────────┐
│ EXTEND Datastructure │
│ (Bucket of Classes) │
└───────────┬───────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
┌────▼─────┐ ┌────▼─────┐ ┌────▼─────┐
│ KeyAdd │ │ RandomAdd│ │ Add │
│ (Assign │ │ (Insert │ │ (Insert │
│ Unique │ │ Random │ │ Values & │
│ Keys) │ │ Entries) │ │ Objects) │
└────▲─────┘ └────▲─────┘ └────▲─────┘
│ │ │
└───────────┬───────┴───────┬───────────┘
│ │
┌──────▼──────┐ ┌────▼───────┐
│ Class Obj │ │ String/Int │
│ (A1–A15) │ │ Values │
│ Methods → │ │ (Headers, │
│ Output Data │ │ Marks etc.)│
└──────▲──────┘ └────▲───────┘
│ │
└───────┬───────┘
│
┌─────────▼─────────┐
│ Retrieval Only │
│ (No Deletion) │
└────────────────────┘
EXTEND Datastructure acts as a central bucket.
KeyAdd → Assigns unique keys to stored data.
RandomAdd → Inserts random entries for variety.
Add → Allows insertion of values (headers, marks, etc.) and class objects.
Class Objects (A1–A15) → Each has its own method, producing outputs like "Iam A1", "Iam a Young fellow".
Retrieval → Data can be read back in sequence.
❌ No Deletion → Once added, data stays permanently.
✨ This diagram shows the data flow from class methods and values into the Extend bucket, and how retrieval works.
🖥️ Output
===============================
EXTEND in Java7.0
[-802204435687571817->
-802204435687571817->
-802204435687571817]
*************************************************************************
Iam a Young fellow
For Extend we can store and retrieve the data , but can't delete it
*************************************************************************
jem
SNO,
SchoolName,
StudentName,
Section A,
Subject1,
Subject2,
Subject3,
Subject4,
Subject5,
TotalMark,
Status,
GRADE
[
1,
EDWillMottSchool,
Andrew,
A1,
75,
75,
75,
75,
75,
375,
Distinction,
B
]
Exdexample.extendprog1+A1
Exdexample.extendprog1+A2
Exdexample.extendprog1+A3
Exdexample.extendprog1+A4
Exdexample.extendprog1+A5
Exdexample.extendprog1+A6
Exdexample.extendprog1+A7
Exdexample.extendprog1+A8
Exdexample.extendprog1+A9
Exdexample.extendprog1+A10
Exdexample.extendprog1+A11
Exdexample.extendprog1+A12
Exdexample.extendprog1+A13
Exdexample.extendprog1+A14
Iam Age A15
*************************************************************************
=========================================================================================================
LARRAY DATASTRUCTURE
===============================================================================================================
🌟 DotWeb 5.0 Program: ArraysExample
✨ Introduction
In this program, we explore the use of LArray from the CLIB package and compare it with the ArrayList from the CUTIL and packages.
The focus is on how LArray differs from a traditional ArrayList in terms of data handling, printing, and flexibility.
🔍 What is the Use of LArray?
LArray belongs to the CLIB package.
Unlike ArrayList, which can only store one datatype at a time, LArray allows multiple datatypes such as integers, strings, and ArrayList data.
However, LArray does not accept objects; it only works with primitive values and collections.
It also has a unique feature: it can print data in a tree format, which is not possible with a standard ArrayList.
🎯 Why Do We Focus on LArray?
We focus on LArray because:
It provides flexibility in storing mixed datatypes.
It supports tree-format printing, making data visualization easier.
It allows removal of elements and returns them as an .ArrayList, which can then be manipulated further (e.g., removing the 2nd element with ar55.remove(1)).
💻 DotWeb 5.0 Program Code
ArraysExample.web
<WEB>
<PACK> ArraysExample
{
public <CLASS> StandardArray
{
public void main()
{
CLIB.LArray larray = new CLIB.LArray("school");
CUTIL.ArrayList arraylist = new CUTIL.ArrayList();
for(int i = 0; i < 10; i++)
arraylist.add(i, i);
larray.add("wilmix");
larray.add("jemin");
larray.add("shalom");
larray.add("1010");
larray.add("101");
larray.add("201");
larray.add(arraylist.ToString());
larray.add("100000000");
larray.add(arraylist.ToString());
larray.printTree();
<OJ7UTIL>.ArrayList ar55 = larray.remove("201");
<PRINTLN>(ar55);
ar55.remove(1);
<PRINTLN>(ar55);
<PRINTLN>("*************************************************************************");
}
}
}
📊 Output
[shalom, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], jemin, 101, school, 100000000, wilmix, 1010]
[shalom, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], jemin, 101, school, 100000000, wilmix, 1010]
🌟 Key Attractions
• LArray vs ArrayList: LArray supports multiple datatypes and tree-format printing, while ArrayList is limited to one datatype.
• Element Removal: Removing returns an ArrayList () that can be further modified.
• Flexibility: LArray allows adding integers, strings, and ArrayList data together.
• Tree Printing: A unique feature that makes data representation more structured.
📐 UML Class Diagram (Textual Representation)
+-------------------+
| LArray | <<class>> (CLIB package)
+-------------------+
| - elements : List |
+-------------------+
| + add(value) |
| + remove(value) : ArrayList (OJ7UTIL) |
| + printTree() |
+-------------------+
|
| uses
v
+-------------------+
| ArrayList | <<class>> (CUTIL / OJ7UTIL package)
+-------------------+
| - items : List |
+-------------------+
| + add(index, val) |
| + remove(index) |
| + toString() |
+-------------------+
🔎 Explanation of Relationships
• LArray → ArrayList
• internally uses for storing and manipulating values.
• When you call on , it returns an object from the package.
• Attributes
• → Represents the internal storage of values (Strings, Integers, ArrayList data).
• Methods
• → Adds a new element (supports multiple datatypes except objects).
• → Removes an element and returns it as an .
• → Prints the elements in a tree-like structure.
🌟 Attraction Points
• Flexibility: Unlike a normal , can store mixed datatypes.
• Tree Printing: Provides a structured visualization of data.
• Integration: Works seamlessly with from and packages.
==============================================================================================================
TREE DATASTRUCTURE
===============================================================================================================
A tree data structure is a hierarchical model used in computer science to organize data in a parent–child relationship, where the topmost node is called the root and each node may have zero or more children. It is widely used for representing hierarchical data such as file systems, organizational charts, and databases.
🌳 Definition of Tree Data Structure
• A tree is a non-linear data structure consisting of nodes connected by edges.
• The root node is the topmost node, with no parent.
• Each node can have child nodes, and those children can themselves be roots of subtrees.
• There are no cycles in a tree, meaning no node can be its own ancestor.
• Trees are often visualized upside down compared to real trees, with the root at the top and branches extending downward.
🔑 Key Terminologies
• Root Node: The starting point of the tree (e.g., in a file system).
• Parent Node: A node that has children.
• Child Node: A node that descends from a parent.
• Leaf Node: A node with no children (end of a branch).
• Subtree: A smaller tree structure within a larger tree.
• Depth: The number of edges from the root to a node.
• Height: The longest path from the root to a leaf.
⚡ Applications of Trees
File Systems: Organizing directories and files.
Databases: Indexing and searching (e.g., B-trees).
Networking: Routing tables and hierarchical structures.
Artificial Intelligence: Decision trees for machine learning.
Compilers: Abstract syntax trees for parsing code.
🚀 Why Trees Are Important
• They allow efficient searching and sorting.
• They represent hierarchical relationships naturally.
• They support recursive algorithms due to their branching structure.
• They are foundational in data indexing, AI, and operating systems.
Note: In short, a tree is a hierarchical, non-linear data structure made of nodes and edges, ideal for representing relationships and enabling efficient operations in computing.
Write a Dotweb5.0 Program to create a Tree and 10 elements , print the tree's size and contents
TreeExample.web
<WEB>
<PACK> TreeExample
{
public <CLASS> CreateTree
{
public void main()
{
<PRINTLN>("*************************************************************************");
<PRINTLN>("Tree in Java7.0");
//create the tree
CLIB.Tree roots <NEW> CLIB.Tree("root");
for (int i = 0; i < 10; i = i + 1)
{
roots.add("item " + i);
}
//print the tree's size and contents
<PRINTLN>(roots.size() + "\n\n");
<PRINTLN>(CLIB.Tree.datas + "\n\n");
}
}
}
📊 Output
11
[item 5, item 9, item 1, item 3, item 7, root, item 4, item 8, item 0, item 2, item 6]
🎨 Beautified Layout
🟢 root
┌─────────┼─────────┐
🔵 item 5 🔵 item 9 🔵 item 1
/ \ / \ / \
🟡 item 3 🟡 item 7 🟡 item 4 🟡 item 8 🟡 item 0
/ \
🟡 item 2 🟡 item 6
✨ Highlights
Root Node → root
Children Nodes → item 5, item 9, item 1
Leaf Nodes → item 3, item 7, item 4, item 8, item 0, item 2, item 6
Total Nodes → 11
=======================================================================================================
Basic DataStructures Simillar to Java for Java Professionals
===============================================================================================================
Why Dotweb5.0 Programming Language simillar to Java? Why Dotweb5.0 Technology is the
More advanced when compared to all technologies ?
Java/J2ee professionals overhead is to learn new datastructures syntax . It did not
looks good. Dotweb5.0 is greater than Webapplication and it follows Remote X Application.
Software is like Coat in every 3 or 5 years coat changes. So new Advanced technology came to the
Software field. So we Java/j2ee should change the coat. and Follow new Advanced technology.
So Dotweb5.0 Advanced Technology with high security , is focused. So i invented a new
concept known as Remote X Application. Dotweb5.0 is a Tool to win any competition in
the software market. Dotweb5.0 is a helper for Java/j2ee , C/c++ and Dotnet technology.
That's why Remote X application is focused. Now before that we will learn the Basics simillar
to Java/J2ee technology which is important for any interviews. We will make
Java/J2ee field and SIT(solomon information technology) field more stable from the competition.
And Dotweb5.0 is advanced than all Technologies in the World. Dotweb5.0 is like Mountains.
Define HashMap in Dotweb5.0
In Dotweb5.0 and Java, a HashMap is a data structure that stores elements in key–value pairs,
where each key is unique and maps to exactly one value.
The Dotweb Collections Framework, implements the Map interface, and internally uses hashing
to provide fast lookups, insertions, and deletions (average time complexity O(1)).
🧩 Key Characteristics of HashMap
• Keys are unique → No duplicate keys allowed.
• Values can be duplicated → Multiple keys can map to the same value.
• Nulls allowed → One key and multiple values are permitted.
• Unordered → Does not preserve insertion order. If you need order, use .
• Not thread-safe → Concurrent access must be synchronized externally or use .
• Performance → Average O(1) for put() ,get() , and remove() operations under good hash distribution.
⚡ Example Usage
Write a Hashmap program in Dotweb 5.0 to add the key and values [Alice=25, Bob=30, Charlie=20, David=40] and Sort by Key and Value Ascending and Descending respectively. And get the value of Alice.
And remove Alice key and value. And finaly check where Alice key and value exists or not.
Program
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" J7HashMap EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
OJ7Lib.J7HashMap map99 = new OJ7Lib.J7HashMap();
map99.put("Alice", 25);
map99.put("Bob", 30);
map99.put("Charlie", 20);
map99.put("David", 40);
<PRINTLN>("Sorted by Key Ascending:");
map99.printSortedByKeyAsc();
<PRINTLN>("Sorted by Key Descending:");
map99.printSortedByKeyDesc();
<PRINTLN>("Sorted by Value Ascending:");
map99.printSortedByValueAsc();
<PRINTLN>("Sorted by Value Descending:");
map99.printSortedByValueDesc();
<PRINTLN>(map99.get("Alice"));
map99.remove("Alice");
<PRINTLN>(map99.containsKey("Alice")); // true
🧩 Program Breakdown
1. Printing a Header
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" J7HashMap EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
This simply prints a decorative header to the console, marking the start of the demo.
2. Creating a J7HashMap
OJ7Lib.J7HashMap map99 = new OJ7Lib.J7HashMap();
map99 is an instance of your custom J7HashMap class (similar to Java’s HashMap).
It will store key–value pairs where keys are names (String) and values are ages (Integer).
3. Adding Entries
map99.put("Alice", 25); map99.put("Bob", 30); map99.put("Charlie", 20); map99.put("David", 40);
Four entries are inserted into the map:
"Alice" → 25
"Bob" → 30
"Charlie" → 20
"David" → 40
4. Sorting by Keys
<PRINTLN>("Sorted by Key Ascending:");
map99.printSortedByKeyAsc();
<PRINTLN>("Sorted by Key Descending:");
map99.printSortedByKeyDesc();
Ascending → Keys will be printed in alphabetical order: Alice, Bob, Charlie, David.
Descending → Keys will be printed in reverse alphabetical order: David, Charlie, Bob, Alice.
5. Sorting by Values
<PRINTLN>("Sorted by Value Ascending:");
map99.printSortedByValueAsc();
<PRINTLN>("Sorted by Value Descending:");
map99.printSortedByValueDesc();
Ascending → Values sorted numerically: Charlie=20, Alice=25, Bob=30, David=40.
Descending → Reverse order: David=40, Bob=30, Alice=25, Charlie=20.
6. Accessing a Value
<PRINTLN>(map99.get("Alice"));
Retrieves the value for key "Alice".
Output: 25.
7. Removing an Entry
map99.remove("Alice");
Deletes the entry for "Alice" from the map.
8. Checking Existence
<PRINTLN>(map99.containsKey("Alice")); // true
After removal, this checks if "Alice" still exists.
Since she was removed, the result should be false (the comment // true looks incorrect).
⚡ Expected Output (Simplified)
------------------------------------------------------------------------------------
J7HashMap EXAMPLES
------------------------------------------------------------------------------------
Sorted by Key Ascending:
Alice=25
Bob=30
Charlie=20
David=40
Sorted by Key Descending:
David=40
Charlie=20
Bob=30
Alice=25
Sorted by Value Ascending:
Charlie=20
Alice=25
Bob=30
David=40
Sorted by Value Descending:
David=40
Bob=30
Alice=25
Charlie=20
25
false
Note:
So this program demonstrates basic HashMap operations (put, get, remove, containsKey) plus custom sorting methods (printSortedByKeyAsc/Desc, printSortedByValueAsc/Desc) that your J7HashMap class provides.
Define Concurrent HashMap
A ConcurrentHashMap in Java is a thread‑safe implementation of the interface that allows multiple threads to read and write data simultaneously without locking the entire map. It is designed for high‑concurrency environments where many threads need to access and modify shared data safely.
⚡ Example Usage
Program
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" J7Concurrent HashMap EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
OJ7Lib.J7ConcurrentHashMap map19 = new OJ7Lib.J7ConcurrentHashMap(16);
// put and get
map19.put("A", 1);
<PRINTLN>(map19.get("A"));
map19 = map19.ComputeIfAbsent(map19, "B", "42");
<PRINTLN>(map19.get("B"));
map19 = map19.ComputeIfPresent(map19, "A", "46");
<PRINTLN>(map19.get("A"));
map19 = map19.Merge(map19, "B", " ", 3);
<PRINTLN>(map19.get("B"));
map19 = map19.Visit(map19, "", "");
<PRINTLN>(map19.get("A"));
map19.remove("B");
if (map19.get("B")NOT=null)
<PRINTLN>("The Key B is found");
else
<PRINTLN>("The Key B is not found");
🧩 Detailed Explanation
🔑 Key Features
• Thread Safety → Unlike , which is not synchronized, ensures safe concurrent access.
• Fine‑grained locking → Instead of locking the whole map, it locks only portions (called segments in older versions, or bins in newer ones). This improves performance.
• No nulls allowed → It does not permit keys or values.
• Atomic operations → Provides methods like , , and that execute atomically.
• Performance → Reads are usually lock‑free, and updates use minimal locking, making it faster than .
• Default concurrency level → Typically 16, meaning up to 16 threads can modify the map
concurrently without blocking each other.
🧩 Step‑by‑Step Explanation
Print a header
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" J7Concurrent HashMap EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
This simply prints a decorative banner to mark the start of the demonstration.
Create a concurrent hash map
OJ7Lib.J7ConcurrentHashMap map19 = new OJ7Lib.J7ConcurrentHashMap(16);
A new J7ConcurrentHashMap object is created with an initial capacity of 16. This is your custom concurrent map implementation.
Put and get a value
map19.put("A", 1); (map19.get("A"));
Adds the key "A" with value 1.
Retrieves and prints the value for "A", which is 1.
Compute if absent
map19 = map19.ComputeIfAbsent(map19, "B", "42"); (map19.get("B"));
If key "B" is not already present, it is added with the value "42".
Prints the value of "B", which becomes "42".
Compute if present
map19 = map19.ComputeIfPresent(map19, "A", "46"); (map19.get("A"));
If key "A" exists, its value is updated to "46".
Prints the new value of "A", which is "46".
Merge values
map19 = map19.Merge(map19, "B", " ", 3); (map19.get("B"));
Merges the existing value of "B" with 3.
The logic in your Merge method adds integers, so "42" (if treated as a number) plus 3 becomes 45.
Prints the updated value of "B".
Visit all entries
map19 = map19.Visit(map19, "", ""); (map19.get("A"));
Iterates through all key–value pairs in the map and prints them.
Then prints the value of "A" again, which is "46".
Remove a key and check existence
map19.remove("B"); if (map19.get("B") NOT = null) ("The Key B is found"); else ("The Key B is not found");
Removes the key "B" from the map.
Checks if "B" still exists. Since it was removed, map19.get("B") returns null.
Prints: “The Key B is not found”.
📊 Summary
This program demonstrates how to use a J7ConcurrentHashMap by:
Adding and retrieving values (put, get).
Conditionally inserting (ComputeIfAbsent).
Conditionally updating (ComputeIfPresent).
Merging values (Merge).
Iterating over entries (Visit).
Removing a key and checking if it still exists (remove, get).
At the end, the program confirms that key "B" has been removed and is no longer found in the map.
🚨 Key Considerations
Use ConcurrentHashMap when multiple threads need to update a shared map.
Avoid it if you need insertion order or sorted order (use ConcurrentSkipListMap instead).
Remember: it disallows null keys and values to prevent ambiguity in concurrent operations.
In short: ConcurrentHashMap is a high‑performance, thread‑safe map designed for concurrent applications,
making it ideal for caches, registries, and shared data structures in multi‑threaded systems.
⚡ Expected Output (Simplified)
------------------------------------------------------------------------------------
J7Concurrent HashMap EXAMPLES
------------------------------------------------------------------------------------
1
42
46
45
A -> 46
B -> 45
46
The Key B is not found
Define ArrayList
An ArrayList is a resizable array implementation provided in Java’s and Dotweb Collections Framework.and for Dotweb5.0 Util package is called as OJ7Lib It’s part of the package and is widely used because it combines the simplicity of arrays with the flexibility of dynamic resizing.
🔑 Key Characteristics of ArrayList
• Dynamic size: Unlike arrays, which have a fixed length, an ArrayList can grow or shrink as elements are added or removed.
• Indexed access: Elements can be accessed directly using their index (just like arrays).
• Ordered collection: Maintains the order of insertion.
• Allows duplicates: You can store duplicate elements.
• Supports null values: Multiple entries are allowed.
• Not synchronized: By default, ArrayList is not thread-safe. For multi-threaded use, you’d need synchronization.
Program for J7Arraylist
<PRINTLN("------------------------------------------------------------------------------------");
<PRINTLN>(" J7ARRAYLIST EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
// Create a J7ArrayList of Strings
OJ7Lib.J7ArrayList names = new OJ7Lib.J7ArrayList();
// Add elements
names.add("Alice");
names.add("Bob");
names.add("Charlie");
names.add("Diana");
<PRINTLN>("Initial list:");
foreach (String name in names) {
<PRINTLN>(name);
}
// Get element by index
<PRINTLN>("\nElement at index 2: " + names.get(2));
// Set element at index
names.set(1, "Bobby");
<PRINTLN>("\nAfter setting index 1 to 'Bobby':");
foreach (String name in names) {
<PRINTLN>(name);
}
// Remove element by index
names.remove(0);
<PRINTLN>("\nAfter removing element at index 0:");
foreach (String name in names) {
<PRINTLN>(name);
}
// Remove element by value
names.remove("Charlie");
<PRINTLN>("\nAfter removing 'Charlie':");
foreach (String name in names) {
<PRINTLN>(name);
}
// Check contains
<PRINTLN>("\nContains 'Diana'? " + names.contains("Diana"));
<PRINTLN>("Contains 'Alice'? " + names.contains("Alice"));
// Size
<PRINTLN>("\nSize of list: " + names.size());
// Clear
names.clear();
<PRINTLN>("\nAfter clear, isEmpty? " + names.isEmpty());
📝 Brief Explanation of the Program
This program demonstrates the use of OJ7Lib.J7ArrayList (similar to Java’s ArrayList) with basic operations:
Initialization
A new J7ArrayList of Strings is created to store names.
Adding Elements
Names like "Alice", "Bob", "Charlie", and "Diana" are added to the list.
Displaying Elements
A foreach loop prints all elements in the list.
Accessing by Index
names.get(2) retrieves the element at index 2 (Charlie).
Updating Elements
names.set(1, "Bobby") replaces "Bob" with "Bobby".
Removing Elements
names.remove(0) removes the first element (Alice).
names.remove("Charlie") removes the element by value.
Checking Existence
names.contains("Diana") returns true.
names.contains("Alice") returns false after removal.
Size of List
names.size() shows the number of elements currently in the list.
Clearing the List
names.clear() removes all elements.
names.isEmpty() confirms the list is empty.
👉 Essentially, the program is a step-by-step demo of ArrayList operations: add, get, set, remove, contains, size, and clear.
⚡ Expected Output (Simplified)
------------------------------------------------------------------------------------
J7ARRAYLIST EXAMPLES
------------------------------------------------------------------------------------
Initial list:
Alice
Bob
Charlie
Diana
Element at index 2: Charlie
After setting index 1 to 'Bobby':
Alice
Bobby
Charlie
Diana
After removing element at index 0:
Bobby
Charlie
Diana
After removing 'Charlie':
Bobby
Diana
Contains 'Diana'? True
Contains 'Alice'? False
Size of list: 2
=============================================================================================
📘 STACK
# 📘 What is a Stack?
- A **stack** is a **linear data structure** that follows the **LIFO (Last In, First Out)** principle.
- This means the **last element pushed** onto the stack will be the **first one popped** out.
- Think of a stack of plates: you add plates on top, and you remove plates from the top.
---
# 📝 Definition of Stack
A **stack** is defined as a collection of elements with two primary operations:
- **PUSH** → Adds an element to the top of the stack.
- **POP** → Removes the element from the top of the stack.
Additional operations often include:
- **peek()** → Views the top element without removing it.
- **size()** → Returns the number of elements in the stack.
- **contains(x)** → Checks if an element exists in the stack.
- **removeElementAt(index)** → Removes element at a specific position.
- **removeAllElements()** → Clears the stack completely.
---
# ⚙️ Dotweb5.0 Example Code Explained
Here’s your code, explained step by step:
```Dotweb5.0
OJ7Lib.<VList><STACK> st = new OJ7Lib.<VList><STACK>(9);
```
- Creates a stack object `st` with capacity `9`.
---
### 1. Pushing Elements
```Dotweb5.0
st.<PUSH>(1);
st.<PUSH>(2);
st.<PUSH>(3);
st.<PUSH>(4);
```
- Adds elements `1, 2, 3, 4` to the stack in order.
- Current stack (top → bottom): **4, 3, 2, 1**
---
### 2. Popping and Peeking
```Dotweb5.0
<PRINTLN>(st.<POP>);
<PRINTLN>(st.peek());
```
- `POP` removes the top element → removes `4`.
- `peek()` shows the new top element → `3`.
---
### 3. More Push Operations
```Dotweb5.0
st.<PUSH>(5);
st.<PUSH>(6);
```
- Adds `5` and `6`.
- Current stack: **6, 5, 3, 2, 1**
---
### 4. Removing by Index
```Dotweb5.0
st.removeElementAt(0);
```
- Removes element at index `0` (bottom-most element → `1`).
- Current stack: **6, 5, 3, 2**
---
### 5. Adding More Elements
```Dotweb5.0
st.<PUSH>(7);
st.<PUSH>(8);
```
- Adds `7` and `8`.
- Current stack: **8, 7, 6, 5, 3, 2**
---
### 6. Checking and Accessing
```Dotweb5.0
<PRINTLN>(st.contains(7));
<PRINTLN>(st.elementAt(0));
<PRINTLN>(st.size());
```
- `contains(7)` → returns `true`.
- `elementAt(0)` → returns bottom-most element → `2`.
- `size()` → returns number of elements → `6`.
---
### 7. Removing All Elements
```Dotweb5.0
st.removeAllElements(st);
<PRINTLN>(st.size());
```
- Clears the stack completely.
- `size()` → returns `0`.
✨ Dotweb5.0 Stack Example
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" <STACK> EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
OJ7Lib.<VList><STACK> st = new OJ7Lib.<VList><STACK>(9);
// -------------------------------
// Push elements onto the stack
// -------------------------------
st.<PUSH>(1);
st.<PUSH>(2);
st.<PUSH>(3);
st.<PUSH>(4);
// -------------------------------
// Pop the top element and peek
// -------------------------------
<PRINTLN>(st.<POP>);
<PRINTLN>(st.peek());
// -------------------------------
// Push more elements
// -------------------------------
st.<PUSH>(5);
st.<PUSH>(6);
// -------------------------------
// Remove element at index 0
// -------------------------------
st.removeElementAt(0);
// -------------------------------
// Push additional elements
// -------------------------------
st.<PUSH>(7);
st.<PUSH>(8);
// -------------------------------
// Check contents and properties
// -------------------------------
<PRINTLN>(st.contains(7));
<PRINTLN>(st.elementAt(0));
<PRINTLN>(st.size());
// -------------------------------
// Remove all elements
// -------------------------------
st.removeAllElements(st);
<PRINTLN>(st.size());
---
# ✅ Final Output (Step by Step)
```
4 // POP result
3 // peek result
true // contains(7)
2 // elementAt(0)
6 // size before clearing
0 // size after clearing
```
---
# 🎯 Conclusion
- The **Dotweb5.0 stack code** demonstrates all major stack operations: **push, pop, peek, contains, elementAt, size, removeElementAt, removeAllElements**.
- It shows how a stack maintains **LIFO order** while still allowing extra operations like removing by index or clearing all elements.
📘 Queue
# 📘 What is a Queue?
- A **queue** is a **linear data structure** that follows the **FIFO (First In, First Out)** principle.
- This means the **first element inserted** into the queue will be the **first one removed**.
- Think of a line at a ticket counter: the person who comes first is served first.
---
# 📝 Definition of Queue
A **queue** is defined as a collection of elements with two primary operations:
- **enqueue** → Adds an element to the rear (end) of the queue.
- **dequeue** → Removes the element from the front of the queue.
Additional operations often include:
- **peek()** → Views the front element without removing it.
- **size()** → Returns the number of elements in the queue.
- **display()** → Shows all elements in the queue.
---
# ⚙️ Dotweb5.0 LinkedQueue Example Code Explained
Here’s your code, explained step by step:
```Dotweb5.0
OJ7Lib.LinkedListQueue q3 = new OJ7Lib.LinkedListQueue();
```
- Creates a new **LinkedQueue object** `q3`.
---
### 1. Enqueue Operations
```Dotweb5.0
q3.enqueue(10);
q3.enqueue(20);
q3.enqueue(30);
q3.enqueue(40);
```
- Adds elements `10, 20, 30, 40` to the queue in order.
- Current queue (front → rear): **10, 20, 30, 40**
---
### 2. Display Queue
```Dotweb5.0
q3.display();
```
- Prints all elements in the queue.
- Output: `10 20 30 40`
---
### 3. Peek Front Element
```Dotweb5.0
<PRINTLN>("Front element: " + q3.peek());
```
- Shows the front element without removing it.
- Output: `Front element: 10`
---
### 4. Dequeue Operation
```Dotweb5.0
q3.dequeue();
```
- Removes the front element (`10`).
- Current queue: **20, 30, 40**
---
### 5. Display Queue Again
```Dotweb5.0
q3.display();
```
- Prints the updated queue.
- Output: `20 30 40`
---
### 6. Queue Size
```Dotweb5.0
<PRINTLN>("Queue size: " + q3.size());
```
- Returns the number of elements in the queue.
- Output: `Queue size: 3`
---
✨ Dotweb5.0 LinkedQueue example code
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" LinkedQueue EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
OJ7Lib.LinkedListQueue q3 = new OJ7Lib.LinkedListQueue();
// -------------------------------
// Enqueue elements into the queue
// -------------------------------
q3.enqueue(10);
q3.enqueue(20);
q3.enqueue(30);
q3.enqueue(40);
// -------------------------------
// Display current queue
// -------------------------------
q3.display();
// -------------------------------
// Peek at the front element
// -------------------------------
<PRINTLN>("Front element: " + q3.peek());
// -------------------------------
// Dequeue one element
// -------------------------------
q3.dequeue();
// -------------------------------
// Display updated queue
// -------------------------------
q3.display();
// -------------------------------
// Show current size
// -------------------------------
<PRINTLN>("Queue size: " + q3.size());
# ✅ Final Output (Step by Step)
------------------------------------------------------------------------------------
LinkedQueue EXAMPLES
------------------------------------------------------------------------------------
10 20 30 40
Front element: 10
20 30 40
Queue size: 3
```
---
# 🎯 Conclusion
- The **LinkedQueue example** demonstrates the **FIFO principle** clearly.
- Operations shown: **enqueue, dequeue, peek, display, size**.
- It highlights how a queue differs from a stack:
- **Stack → LIFO (last in, first out)**
- **Queue → FIFO (first in, first out)**
---
# 📘 Stack vs LinkedQueue
## 🔑 Core Principle
- **Stack** → **LIFO (Last In, First Out)**
- The last element pushed is the first one popped.
- **LinkedQueue** → **FIFO (First In, First Out)**
- The first element enqueued is the first one dequeued.
---
## ⚙️ Operations
| Operation | Stack | LinkedQueue |
|-----------|-------|-------------|
| **Insert** | `push()` → adds element to the **top** | `enqueue()` → adds element to the **rear** |
| **Remove** | `pop()` → removes element from the **top** | `dequeue()` → removes element from the **front** |
| **Peek** | `peek()` → views the **top** element | `peek()` → views the **front** element |
| **Traversal** | From top to bottom | From front to rear |
---
## 📊 Behavior Example
### Stack (LIFO)
```Dotweb5.0
Stack s = new Stack();
s.push(1);
s.push(2);
s.push(3);
<PRINTLN>(s.pop()); // 3
```
- Output: `3` (last in, first out)
### LinkedQueue (FIFO)
```Dotweb5.0
LinkedQueue q = new LinkedQueue();
q.enqueue(1);
q.enqueue(2);
q.enqueue(3);
<PRINTLN>(q.dequeue()); // 1
```
- Output: `1` (first in, first out)
---
## 🏗️ Implementation
- **Stack**: Can be implemented using arrays or linked lists.
- **LinkedQueue**: Typically implemented using linked lists (nodes with pointers to next).
---
## 📌 Use Cases
- **Stack**:
- Undo/Redo functionality
- Expression evaluation (postfix/prefix)
- Backtracking algorithms
- **LinkedQueue**:
- Scheduling tasks
- Order processing systems
- Breadth-first search (BFS) in graphs
---
# 🎯 Conclusion
- **Stack** is about handling the **latest item first** (LIFO).
- **LinkedQueue** is about handling the **earliest item first** (FIFO).
- Both are fundamental data structures but serve **different logical needs** in programming.
📘 J7Queue
# 📘 What is J7Queue?
- **J7Queue** is a queue implementation provided in the Dotweb5.0 library (`OJ7Lib`).
- It follows the **FIFO (First In, First Out)** principle: the first element inserted is the first one removed.
- It supports standard queue operations such as **enqueue, dequeue, peek, size, and isEmpty**.
---
# 📝 Definition of Queue (J7Queue)
A **queue** is a linear data structure with these operations:
- **enqueue(x)** → Adds element `x` to the rear of the queue.
- **dequeue() / j7dequeue()** → Removes the front element.
- **peek()** → Views the front element without removing it.
- **size()** → Returns the number of elements in the queue.
- **isEmpty()** → Checks if the queue has no elements.
---
# ⚙️ Dotweb5.0 J7Queue Example Code Explained
Here’s the code, explained step by step:
```Dotweb5.0
OJ7Lib.J7Queue q = new OJ7Lib.J7Queue(5);
```
- Creates a **J7Queue object** `q` with capacity `5`.
---
### 1. Enqueue Operations
```Dotweb5.0
q.enqueue(1);
q.enqueue(2);
q.enqueue(3);
q.enqueue(4);
```
- Adds elements `1, 2, 3, 4` to the queue.
- Current queue (front → rear): **1, 2, 3, 4**
---
### 2. Peek Front Element
```Dotweb5.0
<PRINTLN>("Front element is: " + q.peek());
```
- Shows the front element without removing it.
- Output: `Front element is: 1`
---
### 3. Dequeue Operation
```Dotweb5.0
q.j7dequeue();
<PRINTLN>("Front element is: " + q.peek());
```
- Removes the front element (`1`).
- New front element is `2`.
- Output: `Front element is: 2`
---
### 4. Queue Size
```Dotweb5.0
<PRINTLN>("Queue size is " + q.size());
```
- Returns the number of elements currently in the queue.
- Output: `Queue size is 3`
---
### 5. Multiple Dequeues
```Dotweb5.0
q.j7dequeue();
q.j7dequeue();
q.j7dequeue();
```
- Removes `2, 3, 4` sequentially.
- Queue becomes empty.
---
### 6. Enqueue Again
```Dotweb5.0
q.enqueue(1123);
<PRINTLN>("Front element is: " + q.peek());
```
- Adds `1123` to the queue.
- Front element is now `1123`.
- Output: `Front element is: 1123`
---
### 7. Check Empty Status
```Dotweb5.0
if (q.isEmpty())
<PRINTLN>("Queue is empty");
else
<PRINTLN>("Queue is not empty");
```
- Since `1123` is present, the queue is **not empty**.
- Output: `Queue is not empty`
---
✨ J7Queue Example Code
// -----------------------------------------------------------------------------
// J7Queue EXAMPLES
// -----------------------------------------------------------------------------
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" J7Queue EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
OJ7Lib.J7Queue q = new OJ7Lib.J7Queue(5);
// -------------------------------
// Enqueue elements into the queue
// -------------------------------
q.enqueue(1);
q.enqueue(2);
q.enqueue(3);
q.enqueue(4);
<PRINTLN>("Front element is: " + q.peek());
// -------------------------------
// Dequeue one element
// -------------------------------
q.j7dequeue();
<PRINTLN>("Front element is: " + q.peek());
// -------------------------------
// Show current size
// -------------------------------
<PRINTLN>("Queue size is: " + q.size());
// -------------------------------
// Remove all remaining elements
// -------------------------------
q.j7dequeue();
q.j7dequeue();
q.j7dequeue();
// -------------------------------
// Enqueue a new element
// -------------------------------
q.enqueue(1123);
<PRINTLN>("Front element is: " + q.peek());
// -------------------------------
// Check if queue is empty
// -------------------------------
if (q.isEmpty())
<PRINTLN>("Queue is empty");
else
<PRINTLN>("Queue is not empty");
# ✅ Final Output (Step by Step)
```
------------------------------------------------------------------------------------
J7Queue EXAMPLES
------------------------------------------------------------------------------------
Front element is: 1
Front element is: 2
Queue size is 3
Front element is: 1123
Queue is not empty
```
---
# 🎯 Conclusion
- The **J7Queue example** demonstrates the **FIFO principle** clearly.
- Operations shown: **enqueue, dequeue, peek, size, isEmpty**.
- It highlights how J7Queue manages elements in order, ensuring the earliest enqueued item is always served first.
📘 J7Hashtable
# 📘 What is a J7Hashtable?
- A **J7Hashtable** is a data structure that stores elements in **key–value pairs**.
- It uses **hashing** to compute an index into an array of buckets, from which the desired value can be found.
- Keys are unique, and each key maps to exactly one value.
- It provides **fast access (average O(1))** for insertion, deletion, and lookup.
---
# 📝 Definition of J7Hashtable
A **Hashtable** is defined as:
- A collection of **key-value pairs**.
- **put(key, value)** → Inserts a mapping into the table.
- **get(key)** → Retrieves the value for a given key.
- **containsKey(key)** → Checks if a key exists.
- **containsValue(value)** → Checks if a value exists.
- **remove(key)** → Removes a key-value pair.
- **size()** → Returns the number of entries.
- **clear()** → Removes all entries.
- **clone()** → Creates a shallow copy of the hashtable.
- **equals()** → Compares two hashtables for equality.
---
# ⚙️ Dotweb5.0 J7Hashtable Example Code Explained
```
<PRINTLN>("-------------------------------------------------------");
<PRINTLN>(" HASHTABLE ");
<PRINTLN>("-------------------------------------------------------");
OJ7Lib.J7HashTable table = new OJ7Lib.J7HashTable();
```
- Creates a new **J7HashTable object** named `table`.
---
### 1. Insert Key-Value Pairs
```
table.put("Apple", 10);
table.put("Banana", 20);
table.put("Cherry", 30);
```
- Adds three entries:
- `"Apple" → 10`
- `"Banana" → 20`
- `"Cherry" → 30`
---
### 2. Check for Key
```
<PRINTLN>("Contains key 'Banana'? " + table.containsKey("Banana"));
```
- Checks if `"Banana"` exists.
- Output: `Contains key 'Banana'? true`
---
### 3. Check for Value
```
<PRINTLN>("Contains value 30? " + table.containsValue(30));
```
- Checks if value `30` exists.
- Output: `Contains value 30? true`
---
### 4. Clone the Hashtable
```
OJ7Lib.J7HashTable copy = table.clone();
<PRINTLN>("Clone contains key 'Apple'? " + copy.containsKey("Apple"));
```
- Creates a copy of the hashtable.
- Checks if `"Apple"` exists in the clone.
- Output: `Clone contains key 'Apple'? true`
---
### 5. Compare Equality
```
<PRINTLN>("Table equals copy? " + table.equals(copy));
```
- Compares `table` and `copy`.
- Output: `Table equals copy? true`
---
### 6. Clear the Hashtable
```
table.clear();
<PRINTLN>("Size after clear: " + table.size());
```
- Removes all entries from `table`.
- Output: `Size after clear: 0`
✨ Dotweb5.0 J7HashTable Example
<PRINTLN>("-------------------------------------------------------");
<PRINTLN>(" HASHTABLE ");
<PRINTLN>("-------------------------------------------------------");
OJ7Lib.J7HashTable table = new OJ7Lib.J7HashTable();
// -------------------------------
// Insert key-value pairs
// -------------------------------
table.put("Apple", 10);
table.put("Banana", 20);
table.put("Cherry", 30);
// -------------------------------
// containsKey()
// -------------------------------
<PRINTLN>("Contains key 'Banana'? " + table.containsKey("Banana")); // true
// -------------------------------
// containsValue()
// -------------------------------
<PRINTLN>("Contains value 30? " + table.containsValue(30)); // true
// -------------------------------
// clone()
// -------------------------------
OJ7Lib.J7HashTable copy = table.clone();
<PRINTLN>("Clone contains key 'Apple'? " + copy.containsKey("Apple")); // true
// -------------------------------
// equals()
// -------------------------------
<PRINTLN>("Table equals copy? " + table.equals(copy)); // true
// -------------------------------
// clear()
// -------------------------------
table.clear();
<PRINTLN>("Size after clear: " + table.size()); // 0
---
# ✅ Final Output (Step by Step)
```
-------------------------------------------------------
HASHTABLE
-------------------------------------------------------
Contains key 'Banana'? true
Contains value 30? true
Clone contains key 'Apple'? true
Table equals copy? true
Size after clear: 0
```
---
# 🎯 Conclusion
- The **J7Hashtable program** demonstrates key operations: **put, containsKey, containsValue, clone, equals, clear, size**.
- It shows how a hashtable manages **fast lookups** using keys and supports cloning and equality checks.
- After clearing, the table becomes empty, confirming the **dynamic nature** of hashtables.
==============================================================================================
📘 TreeSet
# 📘 What is a TreeSet?
- A **TreeSet** is a **sorted set** that stores unique elements in **ascending or descending order**.
- It is typically backed by a **balanced binary search tree**, ensuring efficient operations.
- It automatically maintains **order** and prevents duplicates.
---
# 📝 Definition of TreeSet
A **TreeSet** supports:
- **add(x)** → Insert element `x`.
- **ASCDisplay() / DESCDisplay()** → Show elements in ascending or descending order.
- **higher(x)** → Returns the least element strictly greater than `x`.
- **lower(x)** → Returns the greatest element strictly less than `x`.
- **highest() / lowest()** → Returns maximum or minimum element.
- **pollFirst() / pollLast()** → Removes and returns the first or last element.
- **contains(x)** → Checks if an element exists.
- **removeall()** → Clears all elements.
---
# ⚙️ Dotweb5.0 TreeSet Program Explained
```
<PRINTLN>("-------------------------------------------------------");
<PRINTLN>(" TREE SET DETAILS ");
<PRINTLN>("-------------------------------------------------------");
// Create TreeSet with ASC order (Strings)
OJ7Lib.TreeSet treeset = new OJ7Lib.TreeSet("ASC");
treeset.add("minister");
treeset.add("master");
treeset.add("cad");
treeset.add("phd");
// Create TreeSet with capacity (Integers)
OJ7Lib.TreeSet treeset1 = new OJ7Lib.TreeSet(5);
treeset1.add(13);
treeset1.add(15);
treeset1.add(12);
treeset1.add(1);
// Display elements in ASC order
<PRINTLN>("ASC: " + treeset1.ASCDisplay());
// Find higher and lower elements
<PRINTLN>("higher= " + treeset1.higher(13));
<PRINTLN>("lower= " + treeset1.lower(17));
// Find highest and lowest elements
<PRINTLN>("last= " + treeset1.highest());
<PRINTLN>("first= " + treeset1.lowest());
// Poll first and last elements
<PRINTLN>("PollFirst= " + treeset1.pollFirst());
<PRINTLN>("PollLast= " + treeset1.pollLast());
// Display elements in DESC order
<PRINTLN>("DESC: " + treeset1.DESCDisplay());
// Check if element exists
<PRINTLN>("Contains 151? " + treeset1.list.contains(151));
// Remove all elements
treeset1.removeall();
<PRINTLN>("After removeAll: " + treeset1.list.isEmpty());
```
---
# ✅ Step‑by‑Step Explanation
1. **Create TreeSet (Strings)**
- Stores `"minister"`, `"master"`, `"cad"`, `"phd"` in ascending order.
2. **Create TreeSet (Integers)**
- Stores `13, 15, 12, 1`.
3. **ASCDisplay()**
- Shows elements sorted ascending → `[1, 12, 13, 15]`.
4. **higher(13)**
- Finds the next greater element after `13` → `15`.
5. **lower(17)**
- Finds the greatest element less than `17` → `15`.
6. **highest() / lowest()**
- Highest element → `15`.
- Lowest element → `1`.
7. **pollFirst() / pollLast()**
- Removes and returns first (`1`) and last (`15`).
8. **DESCDisplay()**
- Shows remaining elements in descending order → `[13, 12]`.
9. **contains(151)**
- Checks if `151` exists → `false`.
10. **removeall()**
- Clears all elements.
- `isEmpty()` → `true`.
---
# 🎯 Final Output (Step by Step)
```
-------------------------------------------------------
TREE SET DETAILS
-------------------------------------------------------
ASC: [1, 12, 13, 15]
higher= 15
lower= 15
last= 15
first= 1
PollFirst= 1
PollLast= 15
DESC: [13, 12]
Contains 151? false
After removeAll: true
```
=================================================================================================
📘 TreeMap
# 📘 What is a TreeMap?
- A **TreeMap** is a **map data structure** that stores key–value pairs in **sorted order of keys**.
- It is typically implemented using a **Red-Black Tree** (balanced binary search tree).
- Keys are unique, and each key maps to exactly one value.
- Provides efficient operations: **put, get, remove, containsKey, containsValue, subMap, headMap, tailMap**.
---
# 📝 Definition of TreeMap
A **TreeMap** supports:
- **put(key, value)** → Insert a key-value pair.
- **get(key)** → Retrieve value for a given key.
- **containsKey(key)** → Check if a key exists.
- **containsValue(value)** → Check if a value exists.
- **remove(key)** → Remove a key-value pair.
- **size() / isEmpty()** → Get number of entries or check if empty.
- **keySet() / values()** → Get all keys or values.
- **subMap(from, to)** → Get a portion of the map between two keys.
- **headMap(toKey)** → Get all entries with keys less than `toKey`.
- **tailMap(fromKey)** → Get all entries with keys greater than or equal to `fromKey`.
- **clear()** → Remove all entries.
---
# ✨ Dotweb5.0 TreeMap Example
```
<PRINTLN>("-------------------------------------------------------");
<PRINTLN>(" TREEMAP ");
<PRINTLN>("-------------------------------------------------------");
// -------------------------------
// Create a TreeMap (keys sorted in natural order)
// -------------------------------
OJ7Lib.TreeMap map = new OJ7Lib.TreeMap();
// -------------------------------
// put() - Insert key-value pairs
// -------------------------------
map.put(3, "Three");
map.put(1, "One");
map.put(2, "Two");
map.put(5, "Five");
<PRINTLN>("After put: " + map);
// -------------------------------
// get()
// -------------------------------
<PRINTLN>("Get key 2: " + map.get(2));
// -------------------------------
// containsKey() and containsValue()
// -------------------------------
<PRINTLN>("Contains key 3? " + map.containsKey(3));
<PRINTLN>("Contains value 'Five'? " + map.containsValue("Five"));
// -------------------------------
// remove()
// -------------------------------
map.remove(3);
<PRINTLN>("After remove key 3: " + map);
// -------------------------------
// size() and isEmpty()
// -------------------------------
<PRINTLN>("Size: " + map.size());
<PRINTLN>("Is empty? " + map.isEmpty());
// -------------------------------
// keySet() and values()
// -------------------------------
<PRINTLN>("Key set: " + map.keySet());
<PRINTLN>("Values: " + map.values());
// -------------------------------
// subMap(), headMap(), tailMap()
// -------------------------------
<OJ7UTIL>.SortedMap sub = map.subMap(1, 5);
<PRINTLN>("SubMap(1,5): " + sub);
<OJ7UTIL>.SortedMap head = map.headMap(3);
<PRINTLN>("HeadMap(<3): " + head);
<OJ7UTIL>.SortedMap tail = map.tailMap(2);
<PRINTLN>("TailMap(>=2): " + tail);
// -------------------------------
// clear()
// -------------------------------
map.clear();
<PRINTLN>("After clear: " + map);
```
---
# ✅ Step‑by‑Step Explanation
1. **Create TreeMap** → Keys will be stored in natural ascending order.
2. **put()** → Adds entries: `{1=One, 2=Two, 3=Three, 5=Five}`.
3. **get(2)** → Retrieves `"Two"`.
4. **containsKey(3)** → Returns `true`.
5. **containsValue("Five")** → Returns `true`.
6. **remove(3)** → Removes key `3`. Map becomes `{1=One, 2=Two, 5=Five}`.
7. **size() / isEmpty()** → Size is `3`, not empty.
8. **keySet() / values()** → Keys → `[1, 2, 5]`, Values → `[One, Two, Five]`.
9. **subMap(1,5)** → Returns `{1=One, 2=Two}` (keys between 1 and 5).
10. **headMap(3)** → Returns `{1=One, 2=Two}` (keys less than 3).
11. **tailMap(2)** → Returns `{2=Two, 5=Five}` (keys ≥ 2).
12. **clear()** → Removes all entries. Map becomes `{}`.
---
# 🎯 Final Output (Step by Step)
```
-------------------------------------------------------
TREEMAP
-------------------------------------------------------
After put: {1=One, 2=Two, 3=Three, 5=Five}
Get key 2: Two
Contains key 3? true
Contains value 'Five'? true
After remove key 3: {1=One, 2=Two, 5=Five}
Size: 3
Is empty? false
Key set: [1, 2, 5]
Values: [One, Two, Five]
SubMap(1,5): {1=One, 2=Two}
HeadMap(<3): {1=One, 2=Two}
TailMap(>=2): {2=Two, 5=Five}
After clear: {}
```
# 📘 TreeMap vs TreeSet
Both **TreeMap** and **TreeSet** are part of the **sorted collections** family, but they serve different purposes. Let’s break them down clearly.
---
## 🔑 Core Difference
- **TreeSet** → Stores **unique elements** in **sorted order**.
- **TreeMap** → Stores **key–value pairs** with **keys sorted** in natural order.
---
## ⚙️ Operations Comparison
| Feature / Operation | **TreeSet** | **TreeMap** |
|----------------------|-------------|-------------|
| **Data Stored** | Only **elements** (no duplicates) | **Key–Value pairs** |
| **Ordering** | Elements sorted (ASC/DESC) | Keys sorted (ASC by default) |
| **Insertion** | `add(element)` | `put(key, value)` |
| **Access** | `higher(x), lower(x), pollFirst(), pollLast()` | `get(key), subMap(), headMap(), tailMap()` |
| **Check Existence** | `contains(element)` | `containsKey(key), containsValue(value)` |
| **Remove** | `remove(element), removeall()` | `remove(key), clear()` |
| **Traversal** | ASCDisplay(), DESCDisplay() | keySet(), values() |
---
## 📊 Example Flow
### TreeSet Example
```
OJ7Lib.TreeSet ts = new OJ7Lib.TreeSet("ASC");
ts.add(10);
ts.add(5);
ts.add(20);
<PRINTLN>("ASC: " + ts.ASCDisplay()); // [5, 10, 20]
<PRINTLN>("PollFirst: " + ts.pollFirst()); // 5
<PRINTLN>("DESC: " + ts.DESCDisplay()); // [20, 10]
```
### TreeMap Example
```
OJ7Lib.TreeMap map = new OJ7Lib.TreeMap();
map.put(3, "Three");
map.put(1, "One");
map.put(2, "Two");
<PRINTLN>("Map: " + map); // {1=One, 2=Two, 3=Three}
<PRINTLN>("Get key 2: " + map.get(2)); // Two
<PRINTLN>("SubMap(1,3): " + map.subMap(1,3)); // {1=One, 2=Two}
```
---
## 🎯 Use Cases
- **TreeSet**
- When you need a **sorted list of unique elements**.
- Useful for ranking, maintaining ordered sets, or removing duplicates automatically.
- **TreeMap**
- When you need a **dictionary-like structure** with **sorted keys**.
- Useful for indexing, lookup tables, and range queries (subMap, headMap, tailMap).
---
# ✅ Conclusion
- **TreeSet** → Best for **unique sorted elements**.
- **TreeMap** → Best for **sorted key–value mappings**.
- Both rely on **tree-based structures** to maintain order and provide efficient operations.
---
===============================================================================================
---
📘 Dictionary
# 📘 What is a Dictionary?
- A **Dictionary** is a data structure that stores **key–value pairs**.
- Each **key** is unique and maps to a **value**.
- It allows fast lookups, insertions, and deletions.
- In Dotweb5.0, `Dictionary` is often implemented using a **Hashtable**.
---
# 📝 Definition of Dictionary
A **Dictionary** supports:
- **put(key, value)** → Insert a key-value pair.
- **get(key)** → Retrieve value for a given key.
- **isEmpty()** → Check if dictionary has no entries.
- **keys()** → Get all keys.
- **elements()** → Get all values.
- **remove(key)** → Remove a key-value pair.
- **size()** → Return the number of entries.
---
# ✨ Dotweb5.0 Dictionary Example
```
<PRINTLN>("-------------------------------------------------------");
<PRINTLN>(" Dictionary ");
<PRINTLN>("-------------------------------------------------------");
Dictionary mp = new Hashtable();
// -------------------------------
// put() - Insert key-value pairs
// -------------------------------
mp.put("279", "maths");
mp.put("56", "science");
// -------------------------------
// elements() - Display all values
// -------------------------------
for (Enumeration i = mp.elements(); i.hasMoreElements();) {
<PRINTLN>("Value in Dictionary : " + i.nextElement());
}
// -------------------------------
// get() - Retrieve values by key
// -------------------------------
<PRINTLN>("\nValue at key = 6 : " + mp.get("6"));
<PRINTLN>("Value at key = 279 : " + mp.get("279"));
// -------------------------------
// isEmpty() - Check if dictionary is empty
// -------------------------------
<PRINTLN>("\nThere is no key-value pair : " + mp.isEmpty() + "\n");
// -------------------------------
// keys() - Display all keys
// -------------------------------
for (Enumeration k = mp.keys(); k.hasMoreElements();) {
<PRINTLN>("Keys in Dictionary : " + k.nextElement());
}
// -------------------------------
// remove() - Remove a key-value pair
// -------------------------------
<PRINTLN>("\nRemove : " + mp.remove("279"));
<PRINTLN>("Check the value of removed key : " + mp.get("279"));
// -------------------------------
// size() - Get dictionary size
// -------------------------------
<PRINTLN>("\nSize of Dictionary : " + mp.size());
```
---
# ✅ Step‑by‑Step Explanation
1. **Create Dictionary** → Backed by a Hashtable.
2. **put()** → Adds entries:
- `"279" → "maths"`
- `"56" → "science"`
3. **elements()** → Iterates through values → prints `"maths"`, `"science"`.
4. **get()** →
- Key `"6"` → returns `null` (not found).
- Key `"279"` → returns `"maths"`.
5. **isEmpty()** → Returns `false` (dictionary has entries).
6. **keys()** → Iterates through keys → prints `"279"`, `"56"`.
7. **remove("279")** → Removes key `"279"`.
- Checking again → `null`.
8. **size()** → Returns `1` (only `"56" → "science"` remains).
---
# 🎯 Final Output (Step by Step)
```
-------------------------------------------------------
Dictionary
-------------------------------------------------------
Value in Dictionary : maths
Value in Dictionary : science
Value at key = 6 :
Value at key = 279 : maths
There is no key-value pair : false
Keys in Dictionary : 279
Keys in Dictionary : 56
Remove : maths
Check the value of removed key :
Size of Dictionary : 1
```
---
# 📘 Dictionary vs Hashtable
Both **Dictionary** and **Hashtable** are key–value pair data structures, but they differ in usage and implementation.
---
## 🔑 Core Difference
- **Dictionary** → Abstract class that defines the framework for key–value mappings.
- **Hashtable** → Concrete implementation of Dictionary that actually stores the data.
---
## ⚙️ Operations Comparison
| Feature / Operation | **Dictionary** | **Hashtable** |
|----------------------|----------------|---------------|
| **Type** | Abstract class | Concrete class |
| **Data Stored** | Key–Value pairs | Key–Value pairs |
| **Insertion** | `put(key, value)` | `put(key, value)` |
| **Access** | `get(key)` | `get(key)` |
| **Check Existence** | `isEmpty(), keys(), elements()` | `containsKey(), containsValue()` |
| **Remove** | `remove(key)` | `remove(key)` |
| **Traversal** | `keys(), elements()` | `keySet(), values(), entrySet()` |
| **Implementation** | Defines methods only | Provides actual working implementation |
---
## 📊 Example Flow
### Dictionary Example (Dotweb5.0)
```
Dictionary mp = new Hashtable();
mp.put("279", "maths");
mp.put("56", "science");
<PRINTLN>("Value at key 279: " + mp.get("279")); // maths
<PRINTLN>("Is empty? " + mp.isEmpty()); // false
```
### Hashtable Example (Dotweb5.0)
```
OJ7Lib.J7HashTable table = new OJ7Lib.J7HashTable();
table.put("Apple", 10);
table.put("Banana", 20);
<PRINTLN>("Contains key 'Banana'? " + table.containsKey("Banana")); // true
<PRINTLN>("Size: " + table.size()); // 2
```
---
## 🎯 Use Cases
- **Dictionary**
- Used as a **base class** for defining key–value structures.
- Provides **general methods** but not direct implementation.
- **Hashtable**
- Used when you need a **working implementation** of Dictionary.
- Provides **fast lookups** and supports cloning, equality checks, and clearing.
---
# ✅ Conclusion
- **Dictionary** → Abstract blueprint for key–value mappings.
- **Hashtable** → Concrete implementation that actually stores and manages key–value pairs.
- In Dotweb5.0, you often **declare Dictionary but instantiate Hashtable**, combining both.
===============================================================================================
📘 HashSet
# 📘 What is a HashSet?
- A **HashSet** is a collection that stores **unique elements**.
- It is backed by a **hash table**, which ensures fast insertion, deletion, and lookup.
- Unlike lists, it does **not allow duplicates**.
- Elements are **unordered** (no guaranteed sequence).
---
# 📝 Definition of HashSet
A **HashSet** supports:
- **addItem(x)** → Adds element `x` (ignores duplicates).
- **removeItem(x)** → Removes element `x`.
- **ListItems()** → Displays all elements.
- **size()** → Returns number of elements.
- **isEmpty()** → Checks if set is empty.
- **Contains(x)** → Checks if element exists.
- **Clear()** → Removes all elements.
---
# ✨ Dotweb5.0 HashSet Example
```
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" HASH SET EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
// -------------------------------
// Create HashSet and add elements
// -------------------------------
OJ7Lib.HashSet hashset = new OJ7Lib.HashSet(11);
hashset.addItem("ac");
hashset.addItem(51);
hashset.addItem(5);
hashset.addItem(5); // duplicate ignored
// -------------------------------
// Display elements
// -------------------------------
<PRINTLN>(hashset.ListItems());
// -------------------------------
// Remove an element
// -------------------------------
<PRINTLN>(hashset.removeItem("ac"));
<PRINTLN>(hashset.ListItems());
// -------------------------------
// Show size and check empty
// -------------------------------
<PRINTLN>(hashset.size());
<PRINTLN>(hashset.isEmpty());
<PRINTLN>("**************");
// -------------------------------
// Create another HashSet and add elements
// -------------------------------
OJ7Lib.HashSet hs = new OJ7Lib.HashSet(11);
hs.addItem("Geek");
hs.addItem("For");
hs.addItem("Geeks");
hs.addItem("A");
hs.addItem("B");
hs.addItem("Z");
// -------------------------------
// Display elements
// -------------------------------
<PRINTLN>(hs.ListItems());
// -------------------------------
// Remove an element
// -------------------------------
hs.removeItem("B");
<PRINTLN>(hs.ListItems());
<PRINTLN>(hs.size());
<PRINTLN>("**************");
// -------------------------------
// Check existence and clear set
// -------------------------------
<PRINTLN>(hs.Contains("For"));
<PRINTLN>(hs.isEmpty());
hs.Clear();
// -------------------------------
// Verify after clear
// -------------------------------
<PRINTLN>(hs.Contains("For"));
<PRINTLN>(hs.isEmpty());
<PRINTLN>(hs.ListItems());
```
---
# ✅ Step‑by‑Step Explanation
1. **Create HashSet** → Capacity `11`.
2. **addItem()** → Adds `"ac"`, `51`, `5`. Duplicate `5` ignored.
3. **ListItems()** → Displays elements (unordered).
4. **removeItem("ac")** → Removes `"ac"`.
5. **size() / isEmpty()** → Shows number of elements and empty status.
6. **Second HashSet** → Adds `"Geek", "For", "Geeks", "A", "B", "Z"`.
7. **removeItem("B")** → Removes `"B"`.
8. **Contains("For")** → Returns `true`.
9. **Clear()** → Removes all elements.
10. **Final check** → `Contains("For")` → `false`, `isEmpty()` → `true`, `ListItems()` → empty.
---
# 🎯 Final Output (Step by Step)
------------------------------------------------------------------------------------
HASH SET EXAMPLES
------------------------------------------------------------------------------------
[ac, 51, 5, 5]
true
[51, 5]
2
False
**************
[Geek, For, Geeks, A, B, Z]
[Geek, For, Geeks, A, Z]
5
**************
True
False
True
False
[Geeks, For]
---
# 📘 HashSet vs TreeSet
Both **HashSet** and **TreeSet** are part of the **Set collections** family in Dotweb5.0. They store **unique elements** but differ in ordering and performance.
---
## 🔑 Core Difference
- **HashSet** → Stores unique elements in an **unordered collection** (based on hashing).
- **TreeSet** → Stores unique elements in a **sorted collection** (based on tree structure).
---
## ⚙️ Operations Comparison
| Feature / Operation | **HashSet** | **TreeSet** |
|----------------------|-------------|-------------|
| **Data Stored** | Unique elements | Unique elements |
| **Ordering** | No guaranteed order | Sorted (ASC/DESC) |
| **Insertion** | `addItem(element)` | `add(element)` |
| **Access** | `Contains(element)` | `higher(x), lower(x), pollFirst(), pollLast()` |
| **Remove** | `removeItem(element), Clear()` | `remove(element), removeall()` |
| **Traversal** | `ListItems()` | `ASCDisplay(), DESCDisplay()` |
| **Performance** | Faster (O(1) average for add/search/remove) | Slower (O(log n) due to tree balancing) |
---
## 📊 Example Flow
### HashSet Example (Dotweb5.0)
```
OJ7Lib.HashSet hs = new OJ7Lib.HashSet(11);
hs.addItem("Geek");
hs.addItem("For");
hs.addItem("Geeks");
hs.addItem("A");
hs.addItem("B");
hs.addItem("Z");
<PRINTLN>(hs.ListItems()); // Unordered output
hs.removeItem("B");
<PRINTLN>(hs.ListItems()); // "B" removed
<PRINTLN>(hs.Contains("For")); // true
hs.Clear();
<PRINTLN>(hs.isEmpty()); // true
```
### TreeSet Example (Dotweb5.0)
```
OJ7Lib.TreeSet ts = new OJ7Lib.TreeSet("ASC");
ts.add(13);
ts.add(15);
ts.add(12);
ts.add(1);
<PRINTLN>("ASC: " + ts.ASCDisplay()); // [1, 12, 13, 15]
<PRINTLN>("higher= " + ts.higher(13)); // 15
<PRINTLN>("PollFirst= " + ts.pollFirst()); // 1
<PRINTLN>("DESC: " + ts.DESCDisplay()); // [15, 13, 12]
```
---
## 🎯 Use Cases
- **HashSet**
- Best when you need **fast operations** and don’t care about order.
- Useful for membership checks, duplicate removal, and quick lookups.
- **TreeSet**
- Best when you need **sorted elements**.
- Useful for range queries, ordered traversal, and maintaining natural order.
---
# ✅ Conclusion
- **HashSet** → Faster, unordered, ideal for quick lookups.
- **TreeSet** → Slower, ordered, ideal for sorted collections and range-based queries.
- Both ensure **uniqueness of elements**, but differ in how they organize and access them.
=========================================================================================
📘 ConcurrentHashMap
# 📘 What is a ConcurrentHashMap?
- A **ConcurrentHashMap** is a thread‑safe map that allows multiple threads to access and modify entries concurrently without locking the entire map.
- It is faster than `Hashtable` because it uses **segment-level locking** or fine-grained concurrency.
- It does **not allow null keys or null values**.
- Provides **atomic operations** like `putIfAbsent`, `computeIfAbsent`, `computeIfPresent`, `merge`, etc.
---
# 📝 Definition of J7ConcurrentHashMap (Dotweb5.0)
A **J7ConcurrentHashMap** supports:
- **put(key, value)** → Insert or update a key-value pair.
- **get(key)** → Retrieve value for a given key.
- **remove(key)** → Remove a key-value pair.
- **ComputeIfAbsent(map, key, value)** → Insert value if key is absent.
- **ComputeIfPresent(map, key, value)** → Update value if key is present.
- **Merge(map, key, value, newValue)** → Merge new value with existing one.
- **Visit(map, key, value)** → Traverse or apply an operation across entries.
---
# ✨ Dotweb5.0 J7ConcurrentHashMap Example
```
<PRINTLN>("------------------------------------------------------------------------------------");
<PRINTLN>(" J7Concurrent HashMap EXAMPLES ");
<PRINTLN>("------------------------------------------------------------------------------------");
OJ7Lib.J7ConcurrentHashMap map19 = new OJ7Lib.J7ConcurrentHashMap(16);
// -------------------------------
// put() and get()
// -------------------------------
map19.put("A", 1);
<PRINTLN>(map19.get("A"));
// -------------------------------
// ComputeIfAbsent()
// -------------------------------
map19 = map19.ComputeIfAbsent(map19, "B", "42");
<PRINTLN>(map19.get("B"));
// -------------------------------
// ComputeIfPresent()
// -------------------------------
map19 = map19.ComputeIfPresent(map19, "A", "46");
<PRINTLN>(map19.get("A"));
// -------------------------------
// Merge()
// -------------------------------
map19 = map19.Merge(map19, "B", " ", 3);
<PRINTLN>(map19.get("B"));
// -------------------------------
// Visit()
// -------------------------------
map19 = map19.Visit(map19, "", "");
<PRINTLN>(map19.get("A"));
// -------------------------------
// remove() and put()
// -------------------------------
map19.remove("B");
map19.put("A", null);
map19.put("A", 1);
<PRINTLN>("B=" + map19.get("B"));
<PRINTLN>(map19.get("A"));
```
---
# ✅ Step‑by‑Step Explanation
1. **put("A",1)** → Inserts key `"A"` with value `1`.
- `get("A")` → `1`.
2. **ComputeIfAbsent("B","42")** → Since `"B"` is absent, inserts `"B" → 42`.
- `get("B")` → `42`.
3. **ComputeIfPresent("A","46")** → Since `"A"` exists, updates value to `46`.
- `get("A")` → `46`.
4. **Merge("B"," ",3)** → Merges new value `3` with existing `"B"`.
- `get("B")` → updated value (depending on merge logic, here `3`).
5. **Visit()** → Traverses map entries (implementation-specific).
- `get("A")` → still `46`.
6. **remove("B")** → Removes key `"B"`.
- `get("B")` → `null`.
7. **put("A",null)** → Sets `"A"` to `null`.
**put("A",1)** → Updates `"A"` back to `1`.
- `get("A")` → `1`.
---
# 🎯 Final Output (Step by Step)
```
------------------------------------------------------------------------------------
J7Concurrent HashMap EXAMPLES
------------------------------------------------------------------------------------
1
42
46
3
46
B=
1
```
---
# 📘 ConcurrentHashMap vs Hashtable
Both **ConcurrentHashMap** and **Hashtable** are **Map implementations** that store key–value pairs, but they differ in **thread safety, performance, and usage**.
---
## 🔑 Core Difference
- **Hashtable** → Thread‑safe but uses **synchronized methods**, locking the entire map for every operation.
- **ConcurrentHashMap** → Thread‑safe but uses **fine‑grained concurrency**, allowing multiple threads to operate simultaneously with better performance.
---
## ⚙️ Operations Comparison
| Feature / Operation | **Hashtable** | **ConcurrentHashMap** |
|----------------------|---------------|------------------------|
| **Thread Safety** | ✅ Yes (synchronized, locks entire map) | ✅ Yes (concurrent, locks segments) |
| **Performance** | Slower (blocking all threads during operations) | Faster (multiple threads can read/write concurrently) |
| **Null Keys/Values** | ❌ Not allowed | ❌ Not allowed |
| **Atomic Operations** | ❌ No | ✅ Yes (`putIfAbsent`, `computeIfAbsent`, `computeIfPresent`, `merge`, etc.) |
| **Iteration** | Enumeration (legacy) | Iterator with fail‑safe behavior |
| **Use Case** | Legacy applications needing synchronization | Modern concurrent applications needing high performance |
---
## 📊 Example Flow
### Hashtable Example (Dotweb5.0)
```
OJ7Lib.J7HashTable table = new OJ7Lib.J7HashTable();
table.put("Apple", 10);
table.put("Banana", 20);
<PRINTLN>("Contains key 'Banana'? " + table.containsKey("Banana")); // true
<PRINTLN>("Size: " + table.size()); // 2
```
### ConcurrentHashMap Example (Dotweb5.0)
```
OJ7Lib.J7ConcurrentHashMap map19 = new OJ7Lib.J7ConcurrentHashMap(16);
map19.put("A", 1);
<PRINTLN>(map19.get("A"));
map19 = map19.ComputeIfAbsent(map19, "B", "42");
<PRINTLN>(map19.get("B"));
map19 = map19.ComputeIfPresent(map19, "A", "46");
<PRINTLN>(map19.get("A"));
map19 = map19.Merge(map19, "B", " ", 3);
<PRINTLN>(map19.get("B"));
```
---
## 🎯 Use Cases
- **Hashtable**
- Suitable for **legacy code** where synchronization is required.
- Simple but less efficient in multi‑threaded environments.
- **ConcurrentHashMap**
- Suitable for **modern concurrent applications**.
- Provides **better scalability and performance**.
- Supports **atomic operations** for safe concurrent updates.
---
# ✅ Conclusion
- **Hashtable** → Thread‑safe but slow, locks entire map.
- **ConcurrentHashMap** → Thread‑safe and fast, allows concurrent access with atomic operations.
- In Dotweb5.0, prefer **ConcurrentHashMap** for multi‑threaded programs, while **Hashtable** is mainly for backward compatibility.
— here are the **key differences between ConcurrentHashMap and Hashtable**:
---
## 🔑 Differences
- **Thread Safety**
- **Hashtable** → Uses **synchronized methods**, locking the entire map for every operation.
- **ConcurrentHashMap** → Uses **fine‑grained concurrency**, locking only portions (segments/buckets), allowing multiple threads to work simultaneously.
- **Performance**
- **Hashtable** → Slower in multi‑threaded environments due to global lock.
- **ConcurrentHashMap** → Faster and scalable because multiple threads can read/write concurrently.
- **Null Keys/Values**
- **Hashtable** → Does **not allow null keys or null values**.
- **ConcurrentHashMap** → Also does **not allow null keys or null values**.
- **Atomic Operations**
- **Hashtable** → Does **not support atomic operations** like `putIfAbsent`, `computeIfAbsent`, `merge`.
- **ConcurrentHashMap** → Provides **atomic methods** for safe concurrent updates.
- **Iteration**
- **Hashtable** → Uses **Enumeration** (legacy, not fail‑safe).
- **ConcurrentHashMap** → Uses **iterators** that are **fail‑safe** (do not throw ConcurrentModificationException).
- **Use Case**
- **Hashtable** → Legacy applications needing synchronization.
- **ConcurrentHashMap** → Modern concurrent applications requiring high performance.
---
👉 In short: **Hashtable** is older and locks the whole map, while **ConcurrentHashMap** is modern, faster,
and supports atomic operations with fine‑grained concurrency.
===============================================================================================
===============================================================================================
UNIT - 8 : WNOSQLDb connection with Dotweb5.0 Programming Language
================================================================================================
📘 WNOSQL DB
# 📘 What is Wnosql Database?
- **Wnosql Database (Wnosqldb)** appears to be a **custom Dotweb5.0 NoSQL database system**.
- It follows the **NoSQL paradigm**: storing data in flexible formats (documents, key–value, columnar, graph) rather than rigid relational tables.
- Designed for **scalability, speed, and handling large volumes of unstructured/semi‑structured data**.
---
# 🔑 Why is Wnosql DB considered advanced compared to PostgreSQL?
- **PostgreSQL** is a **relational database (RDBMS)**:
- Uses structured tables, rows, and columns.
- Enforces strict schemas and ACID transactions.
- Best for structured, relational data.
- **Wnosql DB** (like other NoSQL systems):
- Schema‑less → flexible data storage.
- Optimized for **horizontal scaling** (distributing across many servers).
- Handles **big data workloads** and **real‑time queries** better.
- Supports **high concurrency** without locking entire tables.
👉 In short: PostgreSQL is excellent for structured relational data, while Wnosql DB is advanced for **massive, distributed, unstructured data**.
---
# 📊 How much volume can Wnosql DB store?
- NoSQL systems (including Wnosql DB) are designed to handle **terabytes to petabytes of data**.
- Unlike PostgreSQL, which scales vertically (one server), Wnosql DB scales **horizontally** across clusters.
- In practice, storage is limited only by **infrastructure capacity** (number of nodes, disks, and distributed architecture).
---
# ⚙️ Advantages of Wnosql DB
- **Scalability** → Handles massive datasets by distributing across servers.
- **Flexibility** → Schema‑less, supports varied data formats.
- **Performance** → Faster reads/writes for big data workloads.
- **High Availability** → Replication and fault tolerance built in.
- **Concurrency** → Multiple users can query/update simultaneously without bottlenecks.
- **WNOSQL PLSQL ** → Using this we can write Wnosql PLSQL and Wnosql functions, what ever you want.
and it can solve complex queries, behave like OOPS , and Wnosql Program.
- **Learning curve** → Designed like SQL and it stores the data in Shell contains rows and cols.
Very easy to learn.
- **Tooling ecosystem** → Smaller compared to mature RDBMS like PostgreSQL.But you can use
WNOSQL PLSQL to write any database Logic. So WNOSQL act like a data storage management,
PLSQL, Program , User can create any PLSQL queries in a fast manner.
- **Consistency trade‑offs** → WNOSQL also support ACID guarantees for speed.
---
# 👤 Who invented Wnosql DB?
- The **NoSQL movement** originated around **2009**, popularized by companies like **Facebook, Google, Amazon** for handling big data.
- Specific **Wnosql DB** in Dotweb5.0 appears to be a **custom implementation** (likely by the Dotweb5.0 framework authors, e.g., “wilmixjemin.j” as referenced in your program).
---
# ✨ Dotweb5.0 with Wnosql DB Program (Your Example)
```
<WEB>
<USE> Security; // load security packages
<USE> <OJ7UTIL>;
<USE> fx;
<WNOSQL>
<PACK> Program8
{
<CLASS> Prog
{
public void main()
{
// Read file path
String fpath = fx.FileSequentialAccess.Read("filepath.txt");
// Connect to Wnosql DB
String g = WDBASQL.WDBASQLS("datastores", "USEDATABASE", "dbpwds", fpath);
// Authenticate user
String t = WDBASQL.WDBASQLS("dbuser", "dbpwds", 1, "wilmix78", "wilmix78", 1, 5, g);
// Query execution
String qh2 = "SelectAll from datastorehg 4 to 3004 , 1 to 1 ?= A By 1 1 : {0} : {0} :{0}";
wdbaconn.WDBAQUERY(qh2);
// Print timestamps
DateTime aDate = DateTime.Now;
<PRINTLN>(aDate.ToString("HH:mm:ss"));
// Fetch results into ArrayList
<OJ7UTIL>.ArrayList ar = WDBALIB.WDBAQUERY(qh2, t);
<PRINTLN>(ar);
DateTime aDate1 = DateTime.Now;
<PRINTLN>(aDate1.ToString("HH:mm:ss"));
}
}
}
```
---
# 🎯 What This Program Does
1. **Reads a file path** for DB connection.
2. **Connects to Wnosql DB** using credentials.
3. **Executes a query** (`SelectAll from datastorehg`).
4. **Prints timestamps** before and after query execution.
5. **Stores results in ArrayList** and prints them.
---
✅ In summary:
- **Wnosql DB** is a Dotweb5.0 NoSQL database designed for **scalable, flexible, big data storage**.
- It is considered advanced compared to PostgreSQL because of **horizontal scaling and schema‑less design**.
- It can store **massive volumes (terabytes to petabytes)** depending on infrastructure.
- Invented as part of the **NoSQL movement (2009)**, with Dotweb5.0’s **Wnosql DB** being a custom implementation.
---
# 📘 Why Wnosql DB is Lightweight Compared to PostgreSQL
- **Memory Limitation**:
We **cannot load 1 terabyte of data directly into memory** — traditional RDBMS like PostgreSQL rely heavily on structured schemas and memory‑intensive operations, which makes them heavier when handling massive datasets.
- **Wnosql DB Advantage**:
- **Lightweight** → Wnosql DB is designed to be less memory‑intensive.
- **Clustered Storage** → Instead of loading everything into one machine’s memory, Wnosql DB **splits big data across clusters**.
- **Scalable** → It can handle **terabytes or even petabytes** depending on hardware, without overwhelming a single node.
- **Flexible Models** → Supports schema‑less storage, key‑value, columnar, graph, and even row/column formats, making it adaptable to different workloads.
---
# 🎯 Refined Statement
👉 *“Because we can’t load 1 terabyte directly into memory, PostgreSQL struggles with massive datasets. Wnosql DB,
however, is lightweight and cluster‑based, allowing big data to be distributed across nodes.
This makes it more scalable and efficient for handling terabytes or more, depending on hardware capacity.”*
✨ About FileHandling in DOTWEB5.0
# ✨ Write a Dotweb5.0 Program example about FileHandling.
```
<WEB>
<USE> file; // Load file handling packages using Java 7.0 libraries
<PACK> Program8
{
<CLASS> Prog
{
public void main()
{
// Step 1: Define a character array containing the letters 'b', 'a', 'g'
char[] data = new char[]{ 'b', 'a', 'g' };
// Step 2: Write the character array into the file "out7.txt"
// Additional parameters specify related files ("out1.txt", "out2.txt"),
// a label ("OAK"), and index positions (0 to 2)
JFileWriter.Write("out7.txt", data, "out1.txt", "out2.txt", "OAK", 0, 2);
// Step 3: Read the contents of "out7.txt"
// The second parameter (3) indicates the number of characters to read
JFileReader.Read("out7.txt", 3);
// -------------------------------
// Expected Output Trace:
// Step 1 → Write characters: bag
// Step 2 → Read file "out7.txt"
// Step 3 → Display result:
// bag
// -------------------------------
}
}
}
```
---
# 🎯 Final Output
```
bag
```
========================================================
Next Dotweb5 Program about file is given below
# Java7File.web
<WEB>
<USE> fx;
<PACK> ConsoleApp289
{
<CLASS> Java7File
{
public void main()
{
//Print the detail of the file wilmix.txt
<PRINTLN>("Print the detail of file wilmix.txt");
FileDetail.Print("wilmix.txt");
<PRINTLN>("----------------------");
<PRINTLN>("Write a String and Print charater by character from a file wilmix2.txt using FileStream");
// write the String 'he is studying mathematics' in the file wilmix2.txt using FileStream
FileStream.Write("wilmix2.txt", "he is studying mathematics");
// read character by character from a file wilmix2.txt using FileStream
for (int i=0;i< FileStream.Read("wilmix2.txt").size();i++)
Console.Write("" + FileStream.Read("wilmix2.txt").get(i).ToString());
<PRINTLN>("");
<PRINTLN>("----------------------");
<PRINTLN>("Write a String and Print charater by character from a file wilmix3.txt using Buffered ");
// write the String 'horse is going now. now it is not a good time' in the file wilmix3.txt
Buffered.Write("wilmix3.txt", "horse is going now. now it is not a good time");
//
<PRINTLN>("" + Buffered.Read("wilmix3.txt"));
<PRINTLN>("----------------------");
//read a string from file wilmix3.txt and split the string to tokens and get the 2nd token from the string
<PRINTLN>("read a string from file wilmix3.txt and split the string to tokens and get the 2nd token from the string");
<PRINTLN>("" + StringTokens.Split("wilmix3.txt").get(2));
// Console.ReadKey();
}
}
}
---
# ✨ Explanation of the dotweb5.0 Program
### Program Overview
This program, defined inside the `ConsoleApp289` package with the class `Java7File`,
demonstrates **file handling operations** such as writing, reading, and tokenizing
strings using different approaches (`FileDetail`, `FileStream`, `Buffered`, and `StringTokens`).
---
## 🔹 Step 1: Printing File Details
```dotweb5
<PRINTLN>("Print the detail of file wilmix.txt");
FileDetail.Print("wilmix.txt");
```
- The program prints a message indicating that it will display details of the file `wilmix.txt`.
- It then calls `FileDetail.Print("wilmix.txt")` to show the file’s information (such as size, path, or metadata depending on implementation).
---
## 🔹 Step 2: Writing and Reading with FileStream
```dotweb5
<PRINTLN>("Write a String and Print character by character from a file wilmix2.txt using FileStream");
FileStream.Write("wilmix2.txt", "he is studying mathematics");
for (int i=0;i< FileStream.Read("wilmix2.txt").size();i++)
Console.Write("" + FileStream.Read("wilmix2.txt").get(i).ToString());
```
- A message is printed to explain the operation.
- The string `"he is studying mathematics"` is written into the file `wilmix2.txt` using `FileStream.Write`.
- The program then reads the file **character by character** and prints each character sequentially to the console.
---
## 🔹 Step 3: Writing and Reading with Buffered
```dotweb5
<PRINTLN>("Write a String and Print character by character from a file wilmix3.txt using Buffered");
Buffered.Write("wilmix3.txt", "horse is going now. now it is not a good time");
<PRINTLN>("" + Buffered.Read("wilmix3.txt"));
```
- A message is printed to indicate the use of buffered operations.
- The string `"horse is going now. now it is not a good time"` is written into the file `wilmix3.txt`.
- The program then reads the entire content of the file using `Buffered.Read` and prints it directly.
---
## 🔹 Step 4: Splitting String into Tokens
```dotweb5
<PRINTLN>("read a string from file wilmix3.txt and split the string to tokens and get the 2nd token from the string");
<PRINTLN>("" + StringTokens.Split("wilmix3.txt").get(2));
```
- The program explains that it will split the string from `wilmix3.txt` into tokens.
- Using `StringTokens.Split`, the file content is divided into words (tokens).
- It then retrieves and prints the **second token** from the split string.
---
# 🎯 Final Summary
This program demonstrates:
1. **File detail retrieval** (`FileDetail.Print`).
2. **File writing and character-by-character reading** using `FileStream`.
3. **Buffered writing and reading** for efficient file handling.
4. **String tokenization** to extract specific words from a file.
---
# 🎯 Final Output
### Print the detail of file wilmix.txt
```
File name : wilmix.txt
Path: wilmix.txt
Absolute path: C:\Enlight\project\wilmix.txt
Parent: null
Exists : false
```
----------------------
### Write a String and Print character by character from a file wilmix2.txt using FileStream
```
he is studying mathematics
```
----------------------
### Write a String and Print character by character from a file wilmix3.txt using Buffered
```
Data is written Success into file..wilmix3.txt
horse is going now. now it is not a good time
```
----------------------
### Read a string from file wilmix3.txt and split the string to tokens and get the 2nd token from the string
```
going
```
---
Next 3rd File Manipulation Dotweb5.0 Program is given below.....
# FileManipulation.web
<WEB>
<USE> fx;
//load file packages using java7.0 libraries
<PACK> Program2file
{
<CLASS> Prog
{
public void main()
{
// copy file contents from one file to another file
CopyFile.call("out7.txt", "out71.txt");
// create a directory name wilmix
CreateDir.call("wilmix");
// Randomly write to file wilmix1.txt with data [iam going now] from location 11
FileRandomAccess.WriteFile("wilmix1.txt", "iam going now..", 11);
// Randomly read from file wilmix1.txt from position 1 with size 10
String sop = FileRandomAccess.ReadFile("wilmix1.txt", 1, 10);
// print the file contents
<PRINTLN> ("RandomAccess=" + sop);
//Write to file wilmix2.txt with data -> weldone today
FileSequentialAccess.Write("wilmix2.txt", "weldone today");
//Sequentilly Read from file wilmix2.txt
<PRINTLN>("SequentialAccess=" + FileSequentialAccess.Read("wilmix2.txt"));
<PRINTLN>("");
<PRINTLN>("");
// Read Directory contents
ReadDir.call("C:\\test");
String sop1 = "wilmix is good";
// count no of words in a given string sop1
<PRINTLN>("Wordcount=" + WordCount.wordcount(sop1));
// Console.ReadKey();
}
}
}
---
# ✨ Explanation of Program2file (File Manipulation Demo)
### Program Overview
This program demonstrates several **file manipulation techniques** using dotweb5.0 with Java7.0 libraries.
It covers copying files, creating directories, random and sequential file access, reading directory contents,
and counting words in a string.
---
## 🔹 Step 1: Copy File Contents
```Dotweb5
CopyFile.call("out7.txt", "out71.txt");
```
- Copies the contents of `out7.txt` into a new file `out71.txt`.
---
## 🔹 Step 2: Create a Directory
```Dotweb5
CreateDir.call("wilmix");
```
- Creates a directory named **wilmix**.
---
## 🔹 Step 3: Random File Access
```Dotweb5
FileRandomAccess.WriteFile("wilmix1.txt", "iam going now..", 11);
String sop = FileRandomAccess.ReadFile("wilmix1.txt", 1, 10);
<PRINTLN>("RandomAccess=" + sop);
```
- Writes the string `"iam going now.."` into `wilmix1.txt` starting at position 11.
- Reads 10 characters from position 1 in the same file.
- Prints the result with the heading **RandomAccess**.
---
## 🔹 Step 4: Sequential File Access
```Dotweb5
FileSequentialAccess.Write("wilmix2.txt", "weldone today");
<PRINTLN>("SequentialAccess=" + FileSequentialAccess.Read("wilmix2.txt"));
```
- Writes `"weldone today"` into `wilmix2.txt`.
- Reads the file sequentially and prints the result with the heading **SequentialAccess**.
---
## 🔹 Step 5: Read Directory Contents
```Dotweb5
ReadDir.call("C:\\test");
```
- Reads and displays the contents of the directory `C:\test`.
---
## 🔹 Step 6: Word Count in a String
```Dotweb5
String sop1 = "wilmix is good";
<PRINTLN>("Wordcount=" + WordCount.wordcount(sop1));
```
- Takes the string `"wilmix is good"`.
- Counts the number of words in the string.
- Prints the result with the heading **Wordcount**.
---
# 📄 Expected Output
Write to File Sucessfullywilmix1.txt
RandomAccess=
Write to File SuccessFullywilmix2.txt
SequentialAccess= weldone today
orginal
out.txt
Params.txt
ScrollServer1.0.3-EnterpriseEditionv.1
ScrollServer1.0.3-EnterpriseEditionv.1.jar
Wordcount=3
```
---
=====================================================================================================
Dotweb5.0 With Encryption ad Decryption
===============================================================================================
# 📘 What is Encryption?
- **Encryption** is the process of **converting readable data (plaintext)** into an **unreadable format (ciphertext)** using an algorithm.
- Purpose: Protect sensitive information so that only authorized users can access it.
- Example: `"dog is chasing cat"` → `"XyZ@#12..."` (encrypted form).
# 📘 What is Decryption?
- **Decryption** is the reverse process: converting **ciphertext back into plaintext** using the correct key or algorithm.
- Purpose: Allow authorized users to read the original data.
- Example: `"XyZ@#12..."` → `"dog is chasing cat"`.
---
# ⚙️ How Dotweb5.0 is Used for Encryption/Decryption ?
- Dotweb5.0 provides **security libraries** (`j7security.Ojava7Process`) with built‑in methods for encryption and decryption.
- **`j7Encrypt()`** → Encrypts the given text.
- **`Decrypt()`** → Decrypts the previously encrypted text.
- This allows developers to secure data directly inside Dotweb5.0 programs without writing low‑level cryptographic code.
---
# ✨ Dotweb5.0 Program (EncryptDecrypt.web)
```
<WEB>
<PACK> j7security1
{
<CLASS> Prog
{
public void main()
{
// Display HTML header with background color
<PRINTLN>("<html><body bgcolor=gold");
// Step 1: Encrypt text using Dotweb5.0 security function
string sop = j7security.Ojava7Process.j7Encrypt(
"wilmix is going1 , cat is going , dog is chasing cat"
);
// Step 2: Print the encrypted format
<PRINTLN>("Encrypt=" + sop);
<PRINTLN>("<BR><BR><BR><BR><BR><BR>");
<PRINTLN>("------------------------------------------------------------");
<PRINTLN>("------------------------------------------------------------");
<PRINTLN>("<BR><BR>");
// Step 3: Encrypt another text
string sop1 = j7security.Ojava7Process.j7Encrypt(
"wilmix is going , cat is going , dog is chasing cat"
);
// Step 4: Print the encrypted format
<PRINTLN>("Encrypt=" + sop1);
<PRINTLN>("<BR><BR><BR><BR>");
// Step 5: Decrypt the text using Dotweb5.0 security function
<PRINTLN>("Decrypt=" + j7security.Ojava7Process.Decrypt());
<PRINTLN>("<BR><BR><BR><BR>");
// Close HTML body
<PRINTLN>("</body></html>");
<PRINTLN>("------------------------------------------------------------");
}
}
}
```
---
# 🎯 Step‑by‑Step Explanation
1. **Encrypt text** → `j7Encrypt()` converts plaintext into ciphertext.
2. **Print encrypted output** → Shows unreadable secured format.
3. **Encrypt another text** → Demonstrates multiple encryption calls.
4. **Decrypt text** → `Decrypt()` restores original readable data.
5. **Output formatting** → HTML tags used for display in browser.
---
# ✅ Final Output (Simplified)
```
Encrypt= [Encrypted string of first text]
------------------------------------------------------------
Encrypt= [Encrypted string of second text]
Decrypt= wilmix is going , cat is going , dog is chasing cat
------------------------------------------------------------
```
---
# 🌟 Summary
- **Encryption** → Protects data by converting it into unreadable form.
- **Decryption** → Restores original readable data.
- **Dotweb5.0** → Provides built‑in security functions (`j7Encrypt`, `Decrypt`) to make encryption/decryption easy for developers.
# 📘 Why the Output Looks Like Random Symbols
- When you call **`j7security.Ojava7Process.j7Encrypt()`**, the function converts your readable text (plaintext) into **ciphertext**.
- Ciphertext is **not meant to be human‑readable** — it appears as random characters, symbols, and control codes.
- That’s exactly what you’re seeing in your output:
```
<html><body bgcolor=gold
Encrypt=V?n?$>;????I?'%?s7X ...
```
This is the **encrypted representation** of your original string:
`"wilmix is going1 , cat is going , dog is chasing cat"`
---
# ⚙️ Program Flow Recap
1. **Input Plaintext** → `"wilmix is going1 , cat is going , dog is chasing cat"`
2. **Encryption** → `j7Encrypt()` converts it into unreadable ciphertext (random symbols).
3. **Output** → Printed inside HTML with gold background.
4. **Decryption** → Later, calling `Decrypt()` restores the original readable text.
---
# 🎯 Final Output (Simplified Trace)
```
<html><body bgcolor=gold
Encrypt= [Ciphertext with random symbols]
------------------------------------------------------------
Encrypt= [Ciphertext with random symbols]
Decrypt= wilmix is going , cat is going , dog is chasing cat
------------------------------------------------------------
</body></html>
```
---
# 🌟 Key Takeaway
- **Encryption Output** → Random symbols (ciphertext).
- **Decryption Output** → Original readable text.
- Dotweb5.0 makes this process simple by providing built‑in functions (`j7Encrypt`, `Decrypt`) so you don’t need to implement cryptographic algorithms manually.
---
---
# 📘 Plaintext → Ciphertext → Decrypted Text
| Stage | Description | Example Output |
|--------------|-------------|----------------|
| **Plaintext (Input)** | The original readable message you pass into the program. | `wilmix is going , cat is going , dog is chasing cat` |
| **Ciphertext (Encryption)** | The unreadable, scrambled format produced by `j7security.Ojava7Process.j7Encrypt()`. Appears as random symbols and characters. | `V?n?$>;????I?'%?s7X...?` *(example from your program output)* |
| **Decrypted Text (Output)** | The restored readable message produced by `j7security.Ojava7Process.Decrypt()`. | `wilmix is going , cat is going , dog is chasing cat` |
---
# 🎯 Key Takeaway
- **Encryption** → Converts plaintext into ciphertext (random symbols).
- **Decryption** → Converts ciphertext back into the original plaintext.
- **Dotweb5.0** → Simplifies this process with built‑in functions (`j7Encrypt`, `Decrypt`) so developers don’t need to implement cryptographic algorithms manually.
==================================================================================================
Exception in Dotweb5.0
==================================================================================================
## 🔎 Define Exception
**An exception is an event that disrupts the normal flow of a program during execution.
It usually occurs due to invalid operations, missing resources, or logical errors.
Exceptions can be broadly categorized into *checked*, *unchecked*, and *errors*,
each serving different purposes in handling abnormal situations.**
---
## 🔎 What is an Exception?
- **Definition:** An exception is a runtime event that signals an error or unexpected condition in a program.
- **Purpose:** Instead of crashing, programs can *catch* exceptions and handle them gracefully using constructs like `<TRY>`, `<CATCH>`, and `<Finally>`
- **Examples of causes:**
- Accessing invalid array indices
- Dividing by zero
- Missing files or network failures
- Invalid user input
---
## 📂 Types of Exceptions
### 1. **Checked Exceptions**
- Occur at **compile time** and must be handled explicitly.
- Examples:
- `IOException` → when input/output operations fail.
- `SQLException` → database access errors.
- `ClassNotFoundException` → when a class definition is missing.
### 2. **Unchecked Exceptions**
- Occur at **runtime** and are not checked at compile time.
- Usually caused by programming mistakes.
- Examples:
- `ArithmeticException` → divide by zero.
- `ArrayIndexOutOfBoundsException` → invalid array index access.
- `NullPointerException` → accessing methods/fields on a null object.
### 3. **Errors**
- Serious problems that applications typically cannot recover from.
- Examples:
- `OutOfMemoryError` → JVM runs out of memory.
- `StackOverflowError` → excessive recursion.
- `VirtualMachineError` → critical JVM failure.
---
## 📝 Summary Table
| Cateory | When it Occurs | Must Handle? | Examples |
|---------------------|----------------|--------------|----------|
| **Checked** | Compile time | Yes | IOException, SQLException |
| **Unchecked** | Runtime | No (optional)| NullPointerException, ArrayIndexOutOfBoundsException |
| **Errors** | Runtime | No (fatal) | OutOfMemoryError, StackOverflowError |
---
### ✅ Write a Dotweb5.0 Program about Exception
<WEB>
<PACK> exceptionexample
{
<CLASS> Program
{
public void main()
{
<TRY>
{
int[] myNumbers = {15, 21, 123};
<PRINTLN>(myNumbers[10]);
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
}
}
}
}
### ✅ Compilation
- The program **will compile successfully** because the syntax is valid.
- There are no syntax errors in my code.
### ⚠️ Runtime Behavior
- At runtime, the line `myNumbers[10]` tries to access the **11th element** of an array that only has **3 elements** (`index 0, 1, 2`).
- This will throw an **`ArrayIndexOutOfBoundsException`**.
- Since you have a `<CATCH> (Exception e)` block, the exception will be caught, and the program will print:
Error.... System.IndexOutOfRangeException: Index was outside the bounds of the array.
at exceptionexample.Program.Main(String[] args)
### 📝 Conclusion
- **Compilation:** ✅ No error.
- **Execution:** ❌ Throws an exception, but it is caught, so the program continues gracefully.
- **Output:** Prints the error message instead of crashing.
### 🔎 What happens in my DotWeb5.0 program
- The array `myNumbers` has **3 elements**: `{15, 21, 123}`.
- You are trying to access `myNumbers[10]`.
- Since index `10` does not exist (valid indices are `0, 1, 2`), this will cause an **exception at runtime**.
- Because i have wrapped the code in `<TRY>` and `<CATCH> (Exception e)`, the exception will be caught.
- The program will then execute the `<PRINTLN>("Error.... "+e);` line inside the catch block.
---
### ✅ Result
- **Compilation:** The program compiles without error.
- **Execution:** At runtime, it throws an exception, which is caught.
- **Output:**
```
Error.... System.IndexOutOfRangeException: Index was outside the bounds of the array.
at exceptionexample.Program.Main(String[] args)
```
---
👉 In my **DotWeb5.0 program**, the exception i triggered (`myNumbers[10]`) is an **unchecked exception** (`ArrayIndexOutOfBoundsException`).
It was caught by your `<CATCH>` block, so the program printed an error message instead of crashing.
Perfect — let’s compare how **DotWeb5.0** handles exceptions versus a mainstream language like Java.
---
## ⚡ Exception Handling in DotWeb5.0 vs Java
### 1. **Syntax Style**
- **DotWeb5.0:**
Uses **tag-based keywords** like `<TRY>`, `<CATCH>`, `<Finally>`, `<PRINTLN>`.
Example:
```dotweb
<TRY> {
<PRINTLN>("Hello");
} <CATCH>(Exception e) {
<PRINTLN>("Error: " + e);
}
```
- **Java:**
Uses reserved words directly: `try`, `catch`, `finally`, `System.out.println`.
👉 DotWeb5.0 is more *markup-like*, almost XML-flavored, while Java is plain keyword-based.
---
### 2. **Semantics**
- **DotWeb5.0:**
Despite the different syntax, the **behavior mirrors Java**:
- `<TRY>` encloses risky code.
- `<CATCH>` handles exceptions.
- `<Finally>` executes cleanup code.
- `<PRINTLN>` outputs text.
- **Java:**
Same semantics, but stricter about method signatures (`public static void main(String[] args)`).
👉 DotWeb5.0 is designed to be **educational and simplified**, hiding boilerplate.
---
### 3. **Types of Exceptions**
Both DotWeb5.0 and Java recognize similar categories:
- **Checked exceptions** → must be handled (e.g., file errors).
- **Unchecked exceptions** → runtime errors (e.g., array index out of bounds).
- **Errors** → fatal conditions (e.g., out of memory).
👉 In your DotWeb5.0 example, `myNumbers[10]` triggers an **unchecked exception** (`ArrayIndexOutOfBoundsException`).
---
### 4. **Output Behavior**
- **DotWeb5.0:**
Prints `Error.... System.IndexOutOfRangeException: Index was outside the bounds of the array.
at exceptionexample.Program.Main(String[] args)
- **Java:**
Prints different for exception, but requires `System.out.println`.
👉 Functionally identical, but DotWeb5.0 makes it look simpler.
---
## 📝 Summary
- DotWeb5.0 is essentially a **Java-like language with XML-style tags**.
- Exception handling rules are the same: try → catch → finally.
- The difference is **syntax sugar**: DotWeb5.0 hides Java’s boilerplate and makes code look like structured markup.
- Your program demonstrated an **unchecked exception** that was caught and printed.
---
### ✅ Write a Dotweb5.0 Program for Userdefined Exception
# ✨ Program: User-Defined Exception in Dotweb5.0
```dotweb5
<WEB>
<PACK> userdefinedexception
{
<CLASS> Program
{
static void checkAge(int age)
{
if (age < 18)
{
throw new <Arithmetic>("Access denied - You must be at least 30 years old.");
}
else
{
<PRINTLN>("Access granted - You are old enough!");
}
}
public void main()
{
checkAge(20);
}
}
}
```
---
# 📄 Output Headings and Results
### User-Defined Exception Example
```
Access granted - You are old enough!
```
---
# 🎯 Explanation
- The program defines a method **`checkAge(int age)`**.
- If the given age is **less than 18**, it throws a **user-defined Arithmetic exception** with the message:
`"Access denied - You must be at least 30 years old."`
- If the age is **18 or above**, it prints:
`"Access granted - You are old enough!"`
- In the `main` method, the program calls `checkAge(20)`.
- Since `20` is greater than 18, the condition for throwing the exception is not met, and the program prints the success message.
==============================================================================================
OAKJAVA7C compiler with DOTWEB5.0
===============================================================================================
⚡ Here a private class that cannot be accessed by any Java code. When compiled, it generates a `.class` file.
The compiler used is **oakjava7c**. We can compile an `.oakjava7` program using the **oakjava7c** compiler.
👉To run this kind of program, you use the OakJava7 interpreter, for example:
```
java <filename>
```
👉Below is the OakJava7 (JAVA7.0) program:
```oakjava
class Oakjava7Prog
{
public Oakjava7Prog()
{
super();
}
public String j7String(String obj)
{
return obj;
}
public void main()
{
print(j7String("wilmix"));
}
}
```
---
👉 Compilation Output
When compiled, the following messages are displayed:
```
oakjava7c J7String.oakjava7
Jemin Information Technology Copyright 2022
Compiling your OakJava7 (JAVA7.0) program, please wait......
Finished Compiling - no errors.
Process complete - 0 errors
Process completed.
Generated .wl class file J7String.class
```
---
### ✅ Execution Output
When running the program using:
```
java J7String
```
The output displayed is:
```
wilmix
```
---
👉 Writing Your First Program using oakjava7(JAVA7.0) for Dotweb5.0
Create a file named **J7String.oakjava7** with the following code:
```oakjava
class Oakjava7Prog
{
public Oakjava7Prog()
{
super();
}
public String j7String(String obj)
{
return obj;
}
public void main()
{
print(j7String("wilmix"));
}
}
```
👉 Explanation
- `class Oakjava7Prog` → Defines the class.
- `Oakjava7Prog()` → Constructor that calls the superclass constructor.
- `j7String(String obj)` → A method that returns the string passed to it.
- `main()` → Entry point of the program. It prints the result of `j7String("wilmix")`.
---
👉 Compiling the Program
Use the OakJava7 (JAVA7.0) compiler:
```
oakjava7c J7String.oakjava7
```
👉 Sample Compiler Output
```
oakjava7c J7String.oakjava7
Jemin Information Technology Copyright 2022
Compiling your OakJava7 (JAVA7.0) program, please wait......
Finished Compiling - no errors.
Process complete - 0 errors
Process completed.
Generated .wl class file J7String.class
```
---
👉 Running the Program
Run the program using the OakJava7(JAVA7.0) interpreter:
```
java J7String
```
### ✅ Output
```
wilmix
```
---
👉 Notes
- OakJava7 generates `.class` files that are executed by the OakJava interpreter.
- This OakJava7 .class is different from Java class file.
- The syntax is similar to Java but streamlined for OakJava’s environment.
- You will learn more about OakJava7’s compiler and its applications in **web application samples**.
- OakJava7 complier is used with Dotweb5.0 compiler.
**Note:** You will learn more about this compiler and its usage in web application samples.
=================================================
✨ Operator Overloading in Dotweb5.0
Definition
Operator overloading is a feature in Dotweb5.0 that allows you to redefine the behavior of operators (like +, -, *, [], etc.) for user-defined types such as classes and structures. It’s a form of compile-time polymorphism that makes objects behave more like built-in types. For example, you can make the + operator add two objects of a custom Complex class.
The general syntax for operator overloading is:
returnType operator symbol (arguments) {
// custom implementation
}
returnType → The type of value returned (e.g., int, Complex, Vector).
operator → A special keyword used to define operator overloading.
symbol → The operator you want to overload (+, -, *, ==, etc.).
arguments → The operands (can be one for unary operators, two for binary operators).
# ✨ Program: Operator Overloading in Dotweb5.0
```dotweb5
# Operatoroverload.web
<WEB>
<PACK> OperatorOverloadapp {
<CLASS> OFFICE {
private double length; // Length of an OFFICE
private double breadth; // Breadth of an OFFICE
private double height; // Height of an OFFICE
public double getVolume() {
return length * breadth * height;
}
public void setLength(double len) {
length = len;
}
public void setBreadth(double bre) {
breadth = bre;
}
public void setHeight(double hei) {
height = hei;
}
// Overload + operator to add two OFFICE objects.
public static OFFICE operator+ (OFFICE b, OFFICE c) {
OFFICE OFFICE = new OFFICE();
OFFICE.length = b.length + c.length;
OFFICE.breadth = b.breadth + c.breadth;
OFFICE.height = b.height + c.height;
return OFFICE;
}
}
<CLASS> Tester {
public void main() {
OFFICE OFFICE1 = new OFFICE(); // Declare OFFICE1
OFFICE OFFICE2 = new OFFICE(); // Declare OFFICE2
OFFICE OFFICE3 = new OFFICE(); // Declare OFFICE3
double volume = 0.0; // Store the volume
// OFFICE 1 specification
OFFICE1.setLength(7.0);
OFFICE1.setBreadth(50.0);
OFFICE1.setHeight(15.0);
// OFFICE 2 specification
OFFICE2.setLength(12.0);
OFFICE2.setBreadth(13.0);
OFFICE2.setHeight(10.0);
// Volume of OFFICE 1
volume = OFFICE1.getVolume();
<PRINTLN>("Volume of OFFICE1 : {0}", volume);
// Volume of OFFICE 2
volume = OFFICE2.getVolume();
<PRINTLN>("Volume of OFFICE2 : {0}", volume);
// Add two OFFICE objects using overloaded +
OFFICE3 = OFFICE1 + OFFICE2;
// Volume of OFFICE 3
volume = OFFICE3.getVolume();
<PRINTLN>("Volume of OFFICE3 : {0}", volume);
}
}
}
```
---
# 📄 Output Headings and Results
### Volume of OFFICE1
```
Volume of OFFICE1 : 5250.0
```
### Volume of OFFICE2
```
Volume of OFFICE2 : 1560.0
```
### Volume of OFFICE3 (OFFICE1 + OFFICE2)
```
Volume of OFFICE3 : 12285.0
```
---
# 🎯 Explanation
- **OFFICE class** defines dimensions (`length`, `breadth`, `height`) and calculates volume.
- The **operator+** method is overloaded to allow adding two OFFICE objects by summing their dimensions.
- In the **Tester class**, two OFFICE objects are created and initialized.
- Their volumes are calculated and displayed.
- Then, the two OFFICE objects are added using the overloaded `+` operator, producing a new OFFICE object (`OFFICE3`).
- Finally, the volume of the combined OFFICE is printed.
# 🎯 Key Points
Unary operators (like ++, --) take one operand.
Binary operators (like +, -, *) take two operands.
Not all operators can be overloaded (e.g., . (dot), :: (scope resolution), ?: (ternary), sizeof).
Operator overloading improves readability and makes custom types behave naturally.
✨ Dotweb5.0 Pointers
## 📌 Definition of Pointer
A **pointer** is a variable that stores the memory address of another variable, enabling indirect access to data.
In programming notation, a pointer can be represented as:
```
{*} l Pointers(s);
```
Where:
- `{*}` → **Pointer symbol**, indicating that the construct refers to a memory address rather than a direct value.
- `l` → **Pointer object**, the actual variable that holds the address.
- `Pointers` → **Keyword**, denoting the pointer type or declaration.
- `(s)` → **Value passed from a string**, showing that the pointer can reference or be initialized with data coming from a string input.
---
## 🧩 Refined Definition
Thus, a **pointer** can be defined as:
> *A symbolic construct (`{*}`) combined with a pointer object (`l`) and a keyword (`Pointers`) that holds the memory address of a value (`s`), allowing indirect access and manipulation of that value.*
---
This way, my notation `{*} l Pointers(s);` becomes part of the formal definition, showing both the **conceptual role** (address referencing) and the **syntactic representation** (pointer symbol, object, keyword, and value).
--- Pointer symbol
|
v
[ l ] Pointer object
|
v
Pointers(s) Keyword with value
|
v
[ s ] String value in memory
Pointer Diagram
### 🔍 Explanation:
- `---` represents the pointer symbol, indicating that `l` is a pointer.
- `[ l ]` is the pointer object that holds the address of the string value.
- `Pointers(s)` is the keyword construct that wraps the value `s`.
- `[ s ]` is the actual string value stored in memory, which `l` points to.
In C and C++, pointers are variables that store memory addresses. When you print a pointer, it typically displays the memory location where the data is stored. This approach, while powerful, exposes raw memory addresses, which can sometimes lead to security risks if not handled carefully.
Dotweb5.0 introduces a different approach to pointers. Instead of storing the memory location directly, Dotweb5.0 pointers encapsulate the value inside a pointer object. When you print such a pointer object, it displays in a format like:
valueptrs@189441b
This representation hides the actual value and memory details, making the system more secure.
The key benefit of Dotweb5.0 pointers is data protection. By concealing the underlying values and memory addresses, they reduce the risk of accidental exposure or misuse. This abstraction ensures that sensitive information is not directly visible when working with pointers.
Another important aspect is that Dotweb5.0 pointer objects are stored in the heap. This allows for dynamic memory allocation and efficient management of objects, aligning with modern programming practices.
✨ In summary:
Dotweb5.0 pointers provide a secure and modern alternative to traditional C/C++ pointers. By storing values in pointer objects, hiding raw memory details, and managing them in the heap, they enhance both safety and efficiency in software development.
Let see the Dotweb5.0 program about Dotweb5.0 Pointers with Structures.
# ✨ Program: Dotweb5.0 Pointers and Pointer with Structures
```dotweb5
<WEB>
<USE> CUTIL;
<PACK> GFG {
<CLASS> Programs
{
public void main()
{
<Str> s = "ABC School";
int[] marks = new int[5] { 89, 88, 82, 97, 95 };
double total = 0.0;
double percentage = 0.0;
for (int i = 0; i < 5; i++) {
total += marks[i];
}
// Pointer with Structure
int[] marks1 = new int[5] { 69, 68, 52, 100, 95 };
double total1 = 0.0;
double percentage1 = 0.0;
for (int i = 0; i < 5; i++) {
total1 += marks1[i];
}
{*} l Pointers(s);
l.add("101");
l.add("Wilmix");
l.add("Percentage = " + total / 5);
l.add("102");
l.add("Andrew");
l.add("Percentage = " + total1 / 5);
<PRINTLN>("object value= "+l);
for (int i = 0; i NOT= l.size(); i = i + 1) {
<OBJECT> obj = l.GETKEY(i);
// Copy pointer data to Oakjava7 Structure
<STRUCTURE> list <NEW> <STRUCTURE>(l.GETKEY(i));
for (int i11 = 0; i11 NOT= list.size(); i11 = i11 + 1) {
<OBJECT> el = list.ret(i11);
<PRINTLN>("" + el);
}
}
}
}
}
```
---
# 📄 Output Headings and Results
### Student Records using Dotweb5.0 Pointers and Structures
object value= ptrs@189441b
ABC School
101
Wilmix
Percentage = 90.2
102
Andrew
Percentage = 76.8
```
---
# 🎯 Explanation
- **Marks arrays**: Two arrays store marks of students.
- First student’s marks: `89, 88, 82, 97, 95` → Average = `90.2`.
- Second student’s marks: `69, 68, 52, 100, 95` → Average = `76.8`.
- **Pointers**: A Dotweb5.0 pointer (`l`) is created with the string `"ABC School"`.
- **Adding data**: Student IDs, names, and calculated percentages are added to the pointer.
- **Pointer with Structure**: The pointer data is copied into a Dotweb5.0 structure using `GETKEY(i)`.
- **Printing results**: Each element (ID, name, percentage) is retrieved and printed.
# 🎯 About Dotweb5.0 Pointers Explanation
### About Dotweb5.0 Pointers
Dotweb5.0 or Oakjava7 pointers are **more powerful and safer** than traditional C/C++ pointers.
---
### Why Dotweb5.0 Pointers are More Advanced ?
- They follow an **ArrayList-style approach** for adding and retrieving data.
- Can store both **String and Integer data** efficiently.
- ArrayList operations are faster than traditional arrays, making Dotweb5.0 pointers faster than C/C++ pointers.
- Pointer values can be seamlessly passed into **Dotweb5.0 Structures**, enabling structured data manipulation.
---
### Program Flow Recap
- Two sets of student marks are stored and averaged.
- Student IDs, names, and percentages are added to a Dotweb5.0 pointer.
- Pointer data is copied into a **Structure** using `GETKEY(i)`.
- The structure retrieves and prints each element (ID, name, percentage).
---
# 🎯 Extended Explanation
### About Dotweb5.0 Pointers
Dotweb5.0 (Oakjava7) pointers are **more powerful and safer** than traditional C/C++ pointers.
#### Disadvantages of C/C++ Pointers
- Difficult to understand for beginners.
- Can cause segmentation errors or unsafe memory access.
- Incorrect pointer values may corrupt memory.
- May lead to memory leakage.
- Relatively slower compared to normal variables.
#### Advantages of Dotweb5.0 Pointers
- Easy to understand and use.
- Do not cause segmentation errors or unsafe memory access.
- Incorrect values will not corrupt memory.
- Do not cause memory leakage.
- Faster than normal variables.
👉 **CUTIL** is the package used for Dotweb5.0 pointers.
---
### Historical Note
Wilmix Jemin .J (Solomon) has **invented and transformed the concept of pointers in a peak manner**.
No other programming language has achieved this innovation.
The creation of **Dotweb5.0 Datastructures and Dotweb5.0 itself** is regarded as one of the **greatest inventions in programming history**.
---
Great choice 👍 — here’s a **clear side‑by‑side comparison table** showing **C/C++ pointers vs Dotweb5.0 pointers**, including the innovation credit to **Wilmix Jemin (Solomon)**:
---
# 📊 Comparison: C/C++ Pointers vs Dotweb5.0 Pointers
| Aspect | C/C++ Pointers | Dotweb5.0 Pointers |
|--------|----------------|---------------------|
| **Ease of Use** | Difficult to understand, especially for beginners | Easy to understand and intuitive |
| **Error Handling** | Can cause segmentation faults and unsafe memory access | Designed to avoid segmentation errors and unsafe memory access |
| **Memory Safety** | Incorrect values may corrupt memory | Incorrect values do not corrupt memory |
| **Leakage Risk** | May cause memory leakage | Do not cause memory leakage |
| **Performance** | Relatively slower than variables | Faster than variables |
| **Data Handling** | Works with raw memory addresses | Works in **ArrayList style** (adding/retrieving data easily) |
| **Flexibility** | Limited to low-level memory operations | Can store both **String and Integer data** efficiently |
| **Integration** | Not directly integrated with higher-level structures | Pointer values can be passed seamlessly into **Dotweb5.0 Structures** |
| **Innovation** | Traditional, unchanged for decades | **Wilmix Jemin (Solomon)** invented and transformed pointers in a peak manner
— no other language has achieved this. Dotweb5.0 Datastructures and Dotweb5.0 itself are considered **great inventions** |
---
# 🎯 Key Takeaway
Dotweb5.0 pointers combine the **power of ArrayLists** with the **safety of modern memory management**,
making them **faster, safer, and more versatile** than traditional C/C++ pointers.
This innovation by **Wilmix Jemin (Solomon)** is a landmark achievement in programming language design.
---
=================================================================================================
Networking allows two programs (client and server) to communicate with each other.
Client → sends a message.
Server → receives and processes the message.
Instead of writing long socket boilerplate code, Dotweb5.0 uses pointer-style constructs like Stream()->LOGIC(...) to make networking concise and readable.
The client connects to the server and sends a message.
<WEB>
<USE> j7network;
<PACK> sample31
{
public <CLASS> j7client
{
public void main()
{
<PRINTLN>("OakJava7 Networks");
Stream()->
LOGIC(L->{
Oj7Network.J7Client(6677,"tomorrow meeting starts at 5:AM","localhost");
})->
}
}
Print banner: "OakJava7 Networks".
Connect to server at port 6677.
Send message: "tomorrow meeting starts at 5:AM".
C:\terminal1>j7client
OakJava7 Networks
The server will later display the message.
The server listens for incoming connections and prints received messages.
<WEB>
<USE> j7network;
<PACK> sample31
{
public <CLASS> j7server
{
public void main()
{
<PRINTLN>("OakJava7 Networks");
Stream()->
LOGIC(L->{
Oj7Network.J7Socket(6677);
})->
}
}
}
Print banner: "OakJava7 Networks".
Open socket at port 6677.
Wait for client connection.
Print received message.
C:\terminal1>j7server
OakJava7 Networks
J7Message= tomorrow meeting starts at 5:AM
Here’s how they work together:
[j7client] ----> (Socket: localhost:6677) ----> [j7server]
|
| Message: "tomorrow meeting starts at 5:AM"
|
V
[Server prints: J7Message= tomorrow meeting starts at 5:AM]
Multiple Clients: You can run several j7client programs, all connecting to the same j7server.
Different Messages: Each client can send unique messages.
Ports: Change the port number (e.g., 6688) to run multiple servers simultaneously.
Message Logging: Save received messages into a file or database.
Error Handling: Add logic for connection failures or invalid ports.
Security: Encrypt messages before sending (e.g., using Dotweb5.0 or OakJava7’s crypto utilities).
Scalability: Extend to distributed systems where multiple servers handle different tasks.
✨ Why This Example Is Powerful
• Simplicity: Dotweb5.0’s syntax removes boilerplate code, making networking logic concise.
• Clarity: Both programs clearly separate responsibilities—client sends, server receives.
• Scalability: This pattern can be extended to multiple clients, larger messages, or even secure communication.
Dotweb5.0 + OakJava7 makes networking simple and elegant.
The client sends, the server receives.
This model can grow into multi-client systems, secure communication, and enterprise-level applications.
============================================================================================
Note: I will add one more section for this Dotweb5.0 Tutorial, for 1 week i will
closed the office due to my personal reasons. So learn all the concepts that is provided in this
Dotweb5.0 Tutorial. Learn all the Theoretical Dotweb5.0 concepts. I have implemented already
about core Dotweb5.0,its advanced concepts, dotweb5.0 web application, code obfuscation,
single page application, machine learning, data science and Advanced securities.
But Dotweb5.0 RAI (Remote advanced Intelligence) and Remote X application will be released
after 6 months that is Dotweb5.0 Version 2.
# Dotweb5.0 Licensing
- **Professional Edition**
© 2026 Jemin Information Technology / Wilmix Jemin J
Licensed under the GNU General Public License v3.0 (GPLv3).
Suitable for tutorials, documentation, and professional/educational use.