The document discusses multi-threading in Java. It defines multi-threading as allowing multiple threads within a process to execute concurrently. It explains that threads share resources of the process but have their own call stacks and program counters. The document outlines the life cycle of a thread in Java and describes how to create threads by implementing the Runnable interface or extending the Thread class. It provides examples of creating and running threads concurrently in Java.
This document discusses string handling in Java. Some key points:
- Strings are immutable sequences of characters represented by the String class. StringBuffer allows mutable strings.
- Constructors can initialize strings from arrays of characters or other strings. Methods like length(), charAt(), and compareTo() operate on strings.
- Strings can be concatenated, searched, extracted, modified, and converted between cases. StringBuffer supports mutable operations like insertion and deletion.
Java is a programming language and computing platform first released by Sun Microsystems in 1995.Java is fast, secure, and reliable programming platform.
The document discusses input/output files in Java. It covers the key classes used for reading and writing files in Java, including FileInputStream, FileOutputStream, FileReader, and FileWriter. It also discusses byte streams versus character streams, and provides examples of reading and writing to files in Java using these classes. Standard input/output streams like System.in and System.out are also covered.
The document discusses key concepts in object-oriented programming in Java including classes, objects, methods, constructors, and inheritance. Specifically, it explains that in Java, classes define the structure and behavior of objects through fields and methods. Objects are instances of classes that allocate memory at runtime. Methods define the behaviors of objects, and constructors initialize objects during instantiation. Inheritance allows classes to extend the functionality of other classes.
The document discusses multithreading in Java. It defines multithreading as executing multiple threads simultaneously, with threads being lightweight subprocesses that share a common memory area. This allows multitasking to be achieved more efficiently than with multiprocessing. The advantages of multithreading include not blocking the user, performing operations together to save time, and exceptions in one thread not affecting others. The document also covers thread states, creating and starting threads, and common thread methods.
The document discusses methods in Java programming. It explains that methods can be used to divide large blocks of code into smaller, more manageable pieces by grouping related lines of code into reusable functions. This improves readability and maintainability of programs. The document provides examples of using methods without and with parameters and return values. It also covers defining your own methods and using methods from Java library classes.
Constructors in Java are special methods used to initialize objects. They are called when an object is created using the new keyword. There are two types of constructors: default constructors and parameterized constructors. A default constructor is created automatically if no other constructor is defined, while a parameterized constructor allows values to be passed during object creation to initialize the object's fields. Constructors must have the same name as the class, cannot have a return type, and cannot be abstract, static, or final. They are used to set initial values for newly created objects.
String objects are stored in the constant string pool and are immutable. StringBuffer and StringBuilder objects are stored in the heap and are mutable. StringBuffer is thread-safe while StringBuilder is non-thread-safe but faster than StringBuffer. The key differences are that String objects cannot be modified, while StringBuffer and StringBuilder can modify their character sequences via append and insert methods. String concatenation involves more steps than StringBuffer concatenation via the append method.
The document discusses Java programming language and Java virtual machine (JVM). It states that Java code is compiled into bytecode that can run on any JVM, allowing cross-platform portability. The JVM provides a runtime environment and executes bytecode through its components: the bytecode verifier checks for errors, the class loader loads Java classes, the execution engine interprets bytecode into machine code, the garbage collector automatically frees unused memory, and the security manager monitors for security violations.
1) A constructor in Java is a special method that is used to initialize objects and is called when an object is created. It can set initial values for object attributes.
2) There are different types of constructors including default, parameterized, and copy constructors. The default constructor takes no parameters, parameterized constructors take parameters to initialize objects with different values, and copy constructors are used to create a copy of an object.
3) Constructor overloading allows a class to have multiple constructors with the same name but different parameters, allowing objects to be initialized in different ways.
The document discusses several core Java concepts including:
1) Comments in Java code can be single-line or multiline javadoc comments.
2) Classes are fundamental in Java and describe data objects and methods that can be applied to objects.
3) Variables and methods have scopes determined by curly braces and a variable is only available within its scope.
This document discusses the key concepts of object-oriented programming including classes, inheritance, abstraction, encapsulation, and polymorphism. It defines a class as a blueprint that is used to create individual objects that share common properties. Inheritance allows a child class to inherit attributes from a parent class. Abstraction hides background details and shows only relevant information. Encapsulation wraps data and code into a single module. Polymorphism allows functions to have the same name but different signatures or arguments.
Java uses streams to handle input/output operations. Streams provide a standardized way to read from and write to various sources and sinks like files, networks, and buffers. There are byte streams that handle input/output of bytes and character streams that handle characters. Common stream classes include FileInputStream, FileOutputStream, BufferedReader, and BufferedWriter which are used to read from and write to files and console. Streams can be chained together for complex I/O processing.
The document provides an overview of core Java basics. It discusses that Java was originally developed by Sun Microsystems and the latest release is Java SE 8. It also explains that Java is object-oriented, platform independent, simple, architecture neutral, portable, robust, multithreaded, interpreted and distributed. The document then discusses Java environment setup, basic syntax including classes, objects and methods. It also covers primitive data types, constructors, OOP concepts like abstraction, encapsulation, inheritance and polymorphism.
This document discusses I/O streams in Java. It defines streams as sequences of bytes that flow from a source to a destination. Streams can be categorized as character streams for text data or byte streams for raw binary data. Streams are also categorized as data streams that act as sources or destinations, or processing streams that alter or manage stream information. The Java IO package contains classes for defining input and output streams of different types.
Start programming in a more functional style in Java. This is the second in a two part series on lambdas and streams in Java 8 presented at the JoziJug.
In given slide ITVoyagers has tried to explain the concept of constructor in Java. We have used very simple language to make this silde.
We have used few examples to explain the concept.
We cover following points.
- Why we need constructor?
- Use of constructor.
- Type of constructor.
- Examples
- Rules for constructor.
- Advantages of constructor.
......................................................
Hope you will like it.
ITVoyagers is trying to make slides of topics related to IT/CS.
Please visit our blog - itvoyagers.in
The document discusses strings and StringBuffers in Java. Strings are immutable sequences of characters represented by the String class. StringBuffers allow modifying character sequences and are represented by the StringBuffer class. The summary provides an overview of common string and StringBuffer operations like concatenation, extraction, comparison, and modification.
Core Java Tutorial. In case you want to get trained in Spring Framework you can refer here:
<a href="https://www.emexotechnologies.com/courses/java-development-training/core-java-training/">Java Training</a>
The document discusses Java byte codes and the Java Virtual Machine (JVM). It explains that the Java compiler produces intermediate byte code for the JVM rather than platform-specific machine code. The JVM then converts the byte code into machine language and executes it. Byte code acts as an intermediary between the virtual machine and the real machine, allowing Java programs to run on any system that supports the JVM. The document also briefly mentions discussing object-oriented programming concepts.
Strings in Java are objects of the String class that represent sequences of characters. Strings are immutable, meaning their contents cannot be modified once created. The StringBuffer class represents mutable strings that can be modified by methods like append(), insert(), delete(), and replace(). Some key String methods include length(), charAt(), equals(), concat(), and indexOf(), while common StringBuffer methods allow modifying the string through insertion, deletion, replacement and reversal of characters.
The document discusses the super keyword, final keyword, and interfaces in Java.
- The super keyword is used to refer to the immediate parent class and can be used with variables, methods, and constructors. It allows accessing members of the parent class from the child class.
- The final keyword can be used with variables, methods, and classes. It makes variables constant and prevents overriding of methods and inheritance of classes.
- Interfaces in Java allow achieving abstraction and multiple inheritance. They can contain only abstract methods and variables declared with default access modifiers. Classes implement interfaces to provide method definitions.
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesLauren Yew
Kotlin Coroutines is a powerful threading library for Kotlin, released by JetBrains in 2018. At The New York Times, we recently migrated our core libraries and parts of our News app from RxJava to Kotlin Coroutines. In this talk we’ll share lessons learned and best practices to understand, migrate to, and use Kotlin Coroutines & Flows.
In this presentation, you will learn:
What Coroutines are and how they function
How to use Kotlin Coroutines & Flows (with real world examples and demos)
Where and why you should use Coroutines & Flows in your app
How to avoid the pitfalls of Coroutines
Kotlin Coroutines vs. RxJava
Lessons learned from migrating to Kotlin Coroutines from RxJava in large legacy projects & libraries
By the end of this talk, you will be able to apply Kotlin Coroutines to your own app, run the provided sample code yourself, and convince your team to give Kotlin Coroutines a try!
This document discusses threads and multithreading in Java. It defines a thread as the smallest unit of processing and notes that threads are lightweight and execute independently within a process. It covers the Thread class in Java and how to create threads by extending the Thread class or implementing the Runnable interface. The document also discusses thread states, priorities, synchronization, and the advantages of multithreading like improved performance.
The document discusses methods in Java programming. It explains that methods can be used to divide large blocks of code into smaller, more manageable pieces by grouping related lines of code into reusable functions. This improves readability and maintainability of programs. The document provides examples of using methods without and with parameters and return values. It also covers defining your own methods and using methods from Java library classes.
Constructors in Java are special methods used to initialize objects. They are called when an object is created using the new keyword. There are two types of constructors: default constructors and parameterized constructors. A default constructor is created automatically if no other constructor is defined, while a parameterized constructor allows values to be passed during object creation to initialize the object's fields. Constructors must have the same name as the class, cannot have a return type, and cannot be abstract, static, or final. They are used to set initial values for newly created objects.
String objects are stored in the constant string pool and are immutable. StringBuffer and StringBuilder objects are stored in the heap and are mutable. StringBuffer is thread-safe while StringBuilder is non-thread-safe but faster than StringBuffer. The key differences are that String objects cannot be modified, while StringBuffer and StringBuilder can modify their character sequences via append and insert methods. String concatenation involves more steps than StringBuffer concatenation via the append method.
The document discusses Java programming language and Java virtual machine (JVM). It states that Java code is compiled into bytecode that can run on any JVM, allowing cross-platform portability. The JVM provides a runtime environment and executes bytecode through its components: the bytecode verifier checks for errors, the class loader loads Java classes, the execution engine interprets bytecode into machine code, the garbage collector automatically frees unused memory, and the security manager monitors for security violations.
1) A constructor in Java is a special method that is used to initialize objects and is called when an object is created. It can set initial values for object attributes.
2) There are different types of constructors including default, parameterized, and copy constructors. The default constructor takes no parameters, parameterized constructors take parameters to initialize objects with different values, and copy constructors are used to create a copy of an object.
3) Constructor overloading allows a class to have multiple constructors with the same name but different parameters, allowing objects to be initialized in different ways.
The document discusses several core Java concepts including:
1) Comments in Java code can be single-line or multiline javadoc comments.
2) Classes are fundamental in Java and describe data objects and methods that can be applied to objects.
3) Variables and methods have scopes determined by curly braces and a variable is only available within its scope.
This document discusses the key concepts of object-oriented programming including classes, inheritance, abstraction, encapsulation, and polymorphism. It defines a class as a blueprint that is used to create individual objects that share common properties. Inheritance allows a child class to inherit attributes from a parent class. Abstraction hides background details and shows only relevant information. Encapsulation wraps data and code into a single module. Polymorphism allows functions to have the same name but different signatures or arguments.
Java uses streams to handle input/output operations. Streams provide a standardized way to read from and write to various sources and sinks like files, networks, and buffers. There are byte streams that handle input/output of bytes and character streams that handle characters. Common stream classes include FileInputStream, FileOutputStream, BufferedReader, and BufferedWriter which are used to read from and write to files and console. Streams can be chained together for complex I/O processing.
The document provides an overview of core Java basics. It discusses that Java was originally developed by Sun Microsystems and the latest release is Java SE 8. It also explains that Java is object-oriented, platform independent, simple, architecture neutral, portable, robust, multithreaded, interpreted and distributed. The document then discusses Java environment setup, basic syntax including classes, objects and methods. It also covers primitive data types, constructors, OOP concepts like abstraction, encapsulation, inheritance and polymorphism.
This document discusses I/O streams in Java. It defines streams as sequences of bytes that flow from a source to a destination. Streams can be categorized as character streams for text data or byte streams for raw binary data. Streams are also categorized as data streams that act as sources or destinations, or processing streams that alter or manage stream information. The Java IO package contains classes for defining input and output streams of different types.
Start programming in a more functional style in Java. This is the second in a two part series on lambdas and streams in Java 8 presented at the JoziJug.
In given slide ITVoyagers has tried to explain the concept of constructor in Java. We have used very simple language to make this silde.
We have used few examples to explain the concept.
We cover following points.
- Why we need constructor?
- Use of constructor.
- Type of constructor.
- Examples
- Rules for constructor.
- Advantages of constructor.
......................................................
Hope you will like it.
ITVoyagers is trying to make slides of topics related to IT/CS.
Please visit our blog - itvoyagers.in
The document discusses strings and StringBuffers in Java. Strings are immutable sequences of characters represented by the String class. StringBuffers allow modifying character sequences and are represented by the StringBuffer class. The summary provides an overview of common string and StringBuffer operations like concatenation, extraction, comparison, and modification.
Core Java Tutorial. In case you want to get trained in Spring Framework you can refer here:
<a href="https://www.emexotechnologies.com/courses/java-development-training/core-java-training/">Java Training</a>
The document discusses Java byte codes and the Java Virtual Machine (JVM). It explains that the Java compiler produces intermediate byte code for the JVM rather than platform-specific machine code. The JVM then converts the byte code into machine language and executes it. Byte code acts as an intermediary between the virtual machine and the real machine, allowing Java programs to run on any system that supports the JVM. The document also briefly mentions discussing object-oriented programming concepts.
Strings in Java are objects of the String class that represent sequences of characters. Strings are immutable, meaning their contents cannot be modified once created. The StringBuffer class represents mutable strings that can be modified by methods like append(), insert(), delete(), and replace(). Some key String methods include length(), charAt(), equals(), concat(), and indexOf(), while common StringBuffer methods allow modifying the string through insertion, deletion, replacement and reversal of characters.
The document discusses the super keyword, final keyword, and interfaces in Java.
- The super keyword is used to refer to the immediate parent class and can be used with variables, methods, and constructors. It allows accessing members of the parent class from the child class.
- The final keyword can be used with variables, methods, and classes. It makes variables constant and prevents overriding of methods and inheritance of classes.
- Interfaces in Java allow achieving abstraction and multiple inheritance. They can contain only abstract methods and variables declared with default access modifiers. Classes implement interfaces to provide method definitions.
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesLauren Yew
Kotlin Coroutines is a powerful threading library for Kotlin, released by JetBrains in 2018. At The New York Times, we recently migrated our core libraries and parts of our News app from RxJava to Kotlin Coroutines. In this talk we’ll share lessons learned and best practices to understand, migrate to, and use Kotlin Coroutines & Flows.
In this presentation, you will learn:
What Coroutines are and how they function
How to use Kotlin Coroutines & Flows (with real world examples and demos)
Where and why you should use Coroutines & Flows in your app
How to avoid the pitfalls of Coroutines
Kotlin Coroutines vs. RxJava
Lessons learned from migrating to Kotlin Coroutines from RxJava in large legacy projects & libraries
By the end of this talk, you will be able to apply Kotlin Coroutines to your own app, run the provided sample code yourself, and convince your team to give Kotlin Coroutines a try!
This document discusses threads and multithreading in Java. It defines a thread as the smallest unit of processing and notes that threads are lightweight and execute independently within a process. It covers the Thread class in Java and how to create threads by extending the Thread class or implementing the Runnable interface. The document also discusses thread states, priorities, synchronization, and the advantages of multithreading like improved performance.
The document discusses string handling in Java. It covers:
1) Strings are immutable objects that cannot be modified, but new strings can be created from existing ones. StringBuffer and StringBuilder allow mutable strings.
2) Common string operations like comparison, searching, and concatenation are built into the language.
3) Methods like length(), charAt(), substring(), and trim() allow extracting characters from strings.
The document summarizes the String class and its methods in Java. It discusses that String is an immutable sequence of characters represented by the String class. It lists some key methods of the String class like length(), charAt(), equals() for comparing Strings. It also covers String constructors and how to initialize Strings.
In Java, a string is an object that represents a sequence of characters and provides methods to perform operations on strings like compare(), concat(), length(), and substring(). Strings can be created using string literals with double quotes or by converting a character array to a string using the String constructor. The length of a string can be found using the length() method and strings can be created and accessed using the new keyword or string literals.
The document summarizes key concepts about Strings in Java including:
1. Strings can be created using double quotes or by converting a character array to a String.
2. The length() method returns the number of characters in a String.
3. Strings can be concatenated using the + operator or concat() method.
4. The format() method can be used to create formatted String outputs.
5. Common String methods include charAt(), compareTo(), indexOf(), and length().
String is an object that represents a sequence of characters. The three main String classes in Java are String, StringBuffer, and StringTokenizer. String is immutable, while StringBuffer allows contents to be modified. Common string methods include length(), charAt(), substring(), indexOf(), and equals(). The StringBuffer class is similar to String but more flexible as it allows adding, inserting and appending new contents.
String objects in Java are immutable and stored in a string pool to improve performance. The StringBuffer class can be used to create mutable strings that can be modified after creation. It provides methods like append(), insert(), replace(), and delete() to modify the string content. The ensureCapacity() method on StringBuffer is used to reserve enough memory to reduce reallocation as the string is modified.
Wrapper classes allow primitive data types to be used as objects. Wrapper classes include Integer, Double, Boolean etc. Strings in Java are immutable - their values cannot be changed once created. StringBuffer and StringBuilder can be used to create mutable strings that can be modified. StringTokenizer can split a string into tokens based on a specified delimiter.
The document discusses String handling in Java. It describes how Strings are implemented as objects in Java rather than character arrays. It also summarizes various methods available in the String and StringBuffer classes for string concatenation, character extraction, comparison, modification, and value conversion. These methods allow extracting characters, comparing strings, modifying strings, and converting between string and other data types.
String Handling in java
By N.V.Raja Sekhar Reddy
www.technolamp.co.in
Want more interesting...
Watch and Like us @ https://www.facebook.com/Technolamp.co.in
subscribe videos @ http://www.youtube.com/user/nvrajasekhar
This document discusses string handling in Java. It covers key topics like:
- Strings are immutable objects in Java
- The String, StringBuffer, and StringBuilder classes can be used to manipulate strings
- Common string methods like length(), concat(), indexOf(), and replace()
- Strings can be compared using equals(), startsWith(), and compareTo()
- Immutability avoids security issues when strings are passed as parameters
Here are solutions to the exercises:
1. Write a program that reverses a string:
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String input = scanner.nextLine();
String reversed = "";
for (int i = input.length() - 1; i >= 0; i--) {
reversed += input.charAt(i);
}
System.out.println("Reversed string: " + reversed);
}
}
```
2. Write a program to
The document provides an overview of Strings and StringBuilders in Java. It discusses Strings as immutable objects and how StringBuilders can be more efficient for modifying strings. It also covers common String and StringBuilder methods, when to use each, and exceptions in Java using try/catch blocks.
The document summarizes common methods of the String class in Java. It describes methods for creating String objects, finding lengths, converting to other data types, checking for equality, extracting substrings, modifying case, and more. Key methods include length(), toString(), getBytes(), equals(), substring(), trim(), toUpperCase(), and toLowerCase(). The String class in Java provides many useful methods for manipulating and working with String objects.
This document outlines the topics of string handling, multithreaded programming, and Java database connectivity in Java. For string handling, it discusses the String, StringBuffer, and StringBuilder classes and their properties like mutability. It also covers string constructors and methods for extracting, comparing, and modifying strings. For multithreaded programming, it lists the need for multiple threads and concepts like thread states, priorities, and inter-thread communication. For Java database connectivity, it mentions the JDBC architecture and tasks like establishing connections, processing result sets, and transactions.
This document discusses string handling, multithreaded programming, and Java database connectivity in Java. It covers:
- String classes like String, StringBuffer, StringBuilder and the CharSequence interface. It describes string construction and properties.
- Methods for extracting, comparing, modifying and searching strings. This includes charAt(), equals(), replace(), substring() etc.
- Multithreaded programming concepts like threads, states, priorities and communication.
- JDBC architecture and components. It discusses establishing database connections, result sets, batch processing and transactions.
The document provides examples to explain string handling methods and multithreaded programming concepts in Java. It aims to introduce the topics of string handling, mult
This document provides an overview of character and string processing in Java, including defining and manipulating character data, using the String, StringBuilder, and StringBuffer classes, regular expressions for pattern matching, and examples of counting vowels, finding words, and replacing characters in strings. It also describes writing an application to build a word concordance from a document by reading a file, creating a word list, and saving the output.
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyYannis
The doctoral thesis trajectory has been often characterized as a “long and windy road” or a journey to “Ithaka”, suggesting the promises and challenges of this journey of initiation to research. The doctoral candidates need to complete such journey (i) preserving and even enhancing their wellbeing, (ii) overcoming the many challenges through resilience, while keeping (iii) high standards of ethics and (iv) scientific rigor. This talk will provide a personal account of lessons learnt and recommendations from a senior researcher over his 30+ years of doctoral supervision and care for doctoral students. Specific attention will be paid on the special features of the (i) interdisciplinary doctoral research that involves Information and Communications Technologies (ICT) and other scientific traditions, and (ii) the challenges faced in the complex technological and research landscape dominated by Artificial Intelligence.
How Binning Affects LED Performance & Consistency.pdfMina Anis
🔍 What’s Inside:
📦 What Is LED Binning?
• The process of sorting LEDs by color temperature, brightness, voltage, and CRI
• Ensures visual and performance consistency across large installations
🎨 Why It Matters:
• Inconsistent binning leads to uneven color and brightness
• Impacts brand perception, customer satisfaction, and warranty claims
📊 Key Concepts Explained:
• SDCM (Standard Deviation of Color Matching)
• Recommended bin tolerances by application (e.g., 1–3 SDCM for retail/museums)
• How to read bin codes from LED datasheets
• The difference between ANSI/NEMA standards and proprietary bin maps
🧠 Advanced Practices:
• AI-assisted bin prediction
• Color blending and dynamic calibration
• Customized binning for high-end or global projects
Top Cite Articles- International Journal on Soft Computing, Artificial Intell...ijscai
International Journal on Soft Computing, Artificial Intelligence and Applications (IJSCAI) is an open access peer-reviewed journal that provides an excellent international forum for sharing knowledge and results in theory, methodology and applications of Artificial Intelligence, Soft Computing. The Journal looks for significant contributions to all major fields of the Artificial Intelligence, Soft Computing in theoretical and practical aspects. The aim of the Journal is to provide a platform to the researchers and practitioners from both academia as well as industry to meet and share cutting-edge development in the field.
A substation at an airport is a vital infrastructure component that ensures reliable and efficient power distribution for all airport operations. It acts as a crucial link, converting high-voltage electricity from the main grid to the lower voltages needed for various airport facilities. This essay will explore the functions, components, and importance of a substation at an airport.
Functions of an Airport Substation:
Voltage Conversion:
Substations step down high-voltage electricity to lower levels suitable for airport operations, like terminal buildings, runways, and other facilities.
Power Distribution:
They distribute electricity to various loads, including lighting, air conditioning, navigation systems, and ground support equipment.
Grid Stability:
Substations help maintain the stability of the power grid by controlling voltage levels and managing power flows.
Redundancy and Reliability:
Airports often have redundant substations or interconnected systems to ensure uninterrupted power supply, even in case of a fault.
Switching and Control:
Substations provide switching capabilities to connect or disconnect circuits, enabling maintenance and power management.
Protection:
Substations incorporate protective devices, like circuit breakers and relays, to safeguard the power system from faults and ensure safe operation.
Key Components of an Airport Substation:
Transformers: These convert high-voltage electricity to lower voltage levels.
Circuit Breakers: These devices switch circuits on or off, protecting the system from faults.
Busbars: These are large, conductive bars that distribute electricity from transformers to other equipment.
Switchgear: This includes equipment that controls the flow of electricity, such as isolators and switches.
Control and Protection Systems: These systems monitor the substation's performance, detect faults, and automatically initiate corrective actions.
Capacitors: These improve the power factor and reduce losses in the system.
Importance of Airport Substations:
Reliable Power Supply:
Substations are essential for providing reliable power to critical airport functions, ensuring safety and efficiency.
Safe and Efficient Operations:
They contribute to the safe and efficient operation of runways, terminals, and other airport facilities.
Airport Infrastructure:
Substations are an integral part of the airport's infrastructure, enabling various operations and services.
Economic Impact:
Substations support the economic activities of the airport, including passenger and cargo handling.
Modernization and Sustainability:
Modern substations incorporate advanced technologies and systems to improve efficiency, reduce energy consumption, and enhance sustainability.
In conclusion, an airport substation is a crucial component of airport infrastructure, ensuring reliable and efficient power distribution, grid stability, and safe operations.
WIRELESS COMMUNICATION SECURITY AND IT’S PROTECTION METHODSsamueljackson3773
In this paper, the author discusses the concerns of using various wireless communications and how to use
them safely. The author also discusses the future of the wireless industry, wireless communication
security, protection methods, and techniques that could help organizations establish a secure wireless
connection with their employees. The author also discusses other essential factors to learn and note when
manufacturing, selling, or using wireless networks and wireless communication systems.
This presentation highlights project development using software development life cycle (SDLC) with a major focus on incorporating research in the design phase to develop innovative solution. Some case-studies are also highlighted which makes the reader to understand the different phases with practical examples.
David Boutry - Mentors Junior DevelopersDavid Boutry
David Boutry is a Senior Software Engineer in New York with expertise in high-performance data processing and cloud technologies like AWS and Kubernetes. With over eight years in the field, he has led projects that improved system scalability and reduced processing times by 40%. He actively mentors aspiring developers and holds certifications in AWS, Scrum, and Azure.
This study will provide the audience with an understanding of the capabilities of soft tools such as Artificial Neural Networks (ANN), Support Vector Regression (SVR), Model Trees (MT), and Multi-Gene Genetic Programming (MGGP) as a statistical downscaling tool. Many projects are underway around the world to downscale the data from Global Climate Models (GCM). The majority of the statistical tools have a lengthy downscaling pipeline to follow. To improve its accuracy, the GCM data is re-gridded according to the grid points of the observed data, standardized, and, sometimes, bias-removal is required. The current work suggests that future precipitation can be predicted by using precipitation data from the nearest four grid points as input to soft tools and observed precipitation as output. This research aims to estimate precipitation trends in the near future (2021-2050), using 5 GCMs, for Pune, in the state of Maharashtra, India. The findings indicate that each one of the soft tools can model the precipitation with excellent accuracy as compared to the traditional method of Distribution Based Scaling (DBS). The results show that ANN models appear to give the best results, followed by MT, then MGGP, and finally SVR. This work is one of a kind in that it provides insights into the changing monsoon season in Pune. The anticipated average precipitation levels depict a rise of 300–500% in January, along with increases of 200-300% in February and March, and a 100-150% increase for April and December. In contrast, rainfall appears to be decreasing by 20-30% between June and September.
May 2025: Top 10 Read Articles Advanced Information Technologyijait
International journal of advanced Information technology (IJAIT) is a bi monthly open access peer-reviewed journal, will act as a major forum for the presentation of innovative ideas, approaches, developments, and research projects in the area advanced information technology applications and services. It will also serve to facilitate the exchange of information between researchers and industry professionals to discuss the latest issues and advancement in the area of advanced IT. Core areas of advanced IT and multi-disciplinary and its applications will be covered during the conferences.
Impurities of Water and their Significance.pptxdhanashree78
Impart Taste, Odour, Colour, and Turbidity to water.
Presence of organic matter or industrial wastes or microorganisms (algae) imparts taste and odour to water.
Presence of suspended and colloidal matter imparts turbidity to water.
2. Java Strings
• In Java, a string is a sequence of characters. For example, "hello" is a string
containing a sequence of characters 'h', 'e', 'l', 'l', and 'o'.
• We use double quotes to represent a string in Java. For example
/ create a string
String type = "Java programming“
Here, we have created a string variable named type. The variable is initialized with
the string Java Programming.
3. Example: Create a String in Java
class Main {
public static void main(String[] args) {
// create strings
String first = "Java";
String second = "Python";
String third = "JavaScript";
// print strings
System.out.println(first); // print Java
System.out.println(second); // print Python
System.out.println(third); // print JavaScript
}
}
4. String length
• The length() method returns the number of characters in a string.
Example
class Main {
public static void main(String[] args) {
String str1 = "Java is fun";
// returns the length of str1
int length = str1.length();
System.out.println(str1.length());
}
}
// Output: 11
5. String length
length() Syntax
• The syntax of the string's length() method is:
string.length()
length() Arguments
The length() method doesn't take any arguments.
length() Return Value
The length() method returns the length of a given string.
6. Example: Java String length()
class Main {
public static void main(String[] args) {
String str1 = "Java";
String str2 = "";
System.out.println(str1.length()); // 4
System.out.println("Java".length()); // 4
// length of empty string
System.out.println(str2.length()); // 0
// new line is considered a single character
System.out.println("Javan".length()); // 5
System.out.println("Learn Java".length()); // 10
}
7. String constructors
• In Java, strings are represented by the String class, which is part of the
java.lang package (automatically imported in every Java program).
• The String class provides multiple ways (constructors) to create and
initialize string objects.
8. String constructors in java
• String()
• String(String str)
• String(char chars[ ])
• String(char chars[ ], int startIndex, int count)
• String(byte byteArr[ ])
• String(byte byteArr[ ], int startIndex, int count)
9. String()
• To create an empty string, we will call the default constructor. The
general syntax to create an empty string in Java program is as follows:
String s = new String();
• It will create a string object in the heap area with no value.
10. String(String str)
• This constructor will create a new string object in the heap area and
stores the given value in it. The general syntax to construct a string
object with the specified string str is as follows:
String st = new String(String str);
For example:
String s2 = new String("Hello Java");
Here, the object str contains Hello Java.
11. String(char chars[ ])
• This string constructor creates a string object and stores the array of characters in
it. The general syntax to create a string object with a specified array of characters
is as follows:
String str = new String(char char[])
For example:
char chars[] = { 'a', 'b', 'c', 'd' };
String s3 = new String(chars);
The object reference variable s3 contains the address of the value stored in the heap
area.
12. //we will create a string object and store an array of
characters in it.
package stringPrograms;
public class Science {
public static void main(String[ ] args)
{
char chars[] = {'s', 'c', 'i', 'e', 'n', 'c', 'e'};
String s = new String(chars);
System.out.println(s);
}
}
Output:
science
13. 4. String(char chars[ ], int startIndex, int count)
• This constructor creates and initializes a string object with a subrange
of a character array.
• The argument startIndex specifies the index at which the subrange
begins and count specifies the number of characters to be copied. The
general syntax to create a string object with the specified subrange of
character array is as follows:
14. 4. String(char chars[ ], int startIndex, int count)
String str = new String(char chars[ ], int startIndex, int count);
For example:
char chars[] = { 'w', 'i', 'n', 'd', 'o', 'w', 's' };
String str = new String(chars, 2, 3);
The object str contains the address of the value ”ndo” stored in the heap area
because the starting index is 2 and the total number of characters to be copied is 3.
15. package stringPrograms;
public class Windows {
public static void main(String[] args)
{
char chars[] = { 'w', 'i', 'n', 'd', 'o', 'w', 's' };
String s = new String(chars, 0,4);
System.out.println(s);
}
}
Output:
wind
16. Java program where we will create a string object that contains the same characters sequence as
another string object.
package stringPrograms;
public class MakeString {
public static void main(String[] args)
{
char chars[] = { 'F', 'A', 'N' };
String s1 = new String(chars);
String s2 = new String(s1);
System.out.println(s1);
System.out.println(s2);
}
}
Output:
FAN
FAN
17. 5. String(byte byteArr[ ])
• This type of string constructor constructs a new string object by decoding the given array of
bytes (i.e., by decoding ASCII values into the characters) according to the system’s default
character set.
package stringPrograms;
public class ByteArray {
public static void main(String[] args)
{
byte b[] = { 97, 98, 99, 100 }; // Range of bytes: -128 to 127. These byte values will be
converted into corresponding characters.
String s = new String(b);
System.out.println(s);
}
}
Output:
abcd
18. Special string operations in JAVA
• String literals
• Concatenation of strings
• String Conversion using toString( )
• Character extraction
• String comparison
19. string literals
string literal in your program, Java automatically constructs a String object.
Thus string literal can be used to initialize a String object.
For example, the following code fragment creates two equivalent strings:
char chars[] = { 'a', 'b', 'c' };
String s1 = new String(chars);
String s2 = "abc"; // use string literal
● String object is created for every string literal, you can use a string literal
any place you can use a String object.
For example, you can call methods directly on a quoted string as if it were an object
reference, as the following statement shows.
It calls the length( ) method on the string “abc”. As expected, it prints “3”.
System.out.println("abc".length());
20. Concatenation of Strings
Java does not allow operators to be applied to String objects.
The one exception to this rule is the + operator, which concatenates two
strings, producing a String object as the result.
String age = "9";
String s = "He is " + age + " years old.";
This displays the string “He is 9 years old.”
String Concatenation with Other Data Types
You can concatenate strings with other types of data.
Be careful when you mix other types of operations with string concatenation
expressions,
however.
22. String Conversion using toString( )
• If you want to represent any object as a string, toString() method comes into
existence.
• The toString() method returns the String representation of the object.
• If you print any object, Java compiler internally invokes the toString() method on
the object. So overriding the toString() method, returns the desired output, it can
be the state of an object etc. depending on your implementation.
• By overriding the toString() method of the Object class, we can return values of
the object, so we don't need to write much code.
23. Understanding problem without toString() method
class Student{
int rollno;
String name;
String city;
Student(int rollno, String name, String city){
this.rollno=rollno;
this.name=name;
this.city=city;
}
public static void main(String args[]){
Student s1=new Student(101,"Raj","lucknow");
Student s2=new Student(102,"Vijay","ghaziabad");
System.out.println(s1);//compiler writes here s1.toString()
System.out.println(s2);//compiler writes here s2.toString()
}
}
Output:
Student@1fee6fc
in the above example, printing s1 and s2 prints the hashcode values of
the objects but I want to print the values of these objects. Since Java
compiler internally calls toString() method, overriding this method will
return the specified values.
24. Example of Java toString() method
class Student{
int rollno;
String name;
String city;
Student(int rollno, String name, String city){
this.rollno=rollno;
this.name=name;
this.city=city;
}
public String toString(){//overriding the toString() method
return rollno+" "+name+" "+city;
}
public static void main(String args[]){
Student s1=new Student(101,"Raj","lucknow");
Student s2=new Student(102,"Vijay","ghaziabad");
System.out.println(s1);//compiler writes here s1.toString()
System.out.println(s2);//compiler writes here s2.toString()
}
}
Output:
101 Raj lucknow
102 Vijay ghaziabad
25. Character extraction
• The String class in Java provides several ways to extract characters from a String object
1. charAt(int index):
This method is used to return the char value at the specified index.
The value of the index must be nonnegative and specify a location within the string.
For example:
char ch;
ch = "abc".charAt(1);
Result:
assigns the value “b” to ch.
26. Character extraction
2. getChars( )
• To extract more than one character from a String object, we can use this method.
General form:
void getChars(int sourceStart, int sourceEnd, char target[ ], int targetStart)
• Here, sourceStart specifies the starting index of the substring, and sourceEnd specifies an
index that is one past the end of the desired substring. The variable target specifies the
resultant array.
27. class getCharsDemo
{
public static void main(String args[])
{
String s = "This is a demo of the getChars method.";
int start = 10;
int end = 14;
char buf[] = new char[end - start];
s.getChars(start, end, buf, 0);
System.out.println(buf);
}
}
Output:
demo
28. 3. getBytes( ):
This is an alternative method to getChars( ). It stores the characters in a byte array.
General form:
byte[ ] getBytes( )
4. toCharArray( )
To convert all the characters of a String object into a character array, this method is used.
It returns a character array for the given string.
General form:
char[ ] toCharArray( )
29. String Comparison
• The String class in Java includes several methods to compare strings
or substrings
• Some of the important string operations in Java to compare strings are
given below:
1. equals( ) and equalsIgnoreCase( )
2. compareTo()
3. compareToIgnoreCase():
30. 1. equals( ) and equalsIgnoreCase( )
equals( ) and equalsIgnoreCase( )
To compare two strings for equality, use equals( ). It has this general form:
boolean equals(Object str)
Here, str is the String object being compared with the invoking String object.
It returns true if the strings contain the same characters in the same order, and false otherwise.
The comparison is case-sensitive.
equalsIgnoreCase( ).
When it compares two strings, it considers A-Z to be the same as a-z.
It has this general form: boolean equalsIgnoreCase(String str)
Here, str is the String object being compared with the invoking String object. It, too, returns
true if the strings contain the same characters in the same order, and false otherwise.
32. The equals( ) method and the “==”operator perform different functions.
The equals( ) method compares the characters of a String object, whereas the ==
operator compares the references of two string objects to see whether they refer
to the same instance.
A simple program to demonstrate the above difference is given below:
The variable s1 is pointing to the String "Hello". The object pointed by s2 is
constructed with the help of s1. Thus, the values inside the two String objects are
the same, but they are distinct objects.
34. 2. compareTo()
The compareTo() method of the Java String class compares the string lexicographically. It returns a
positive, negative, or zero value. To perform a sorting operation on strings, the compareTo() method
comes in handy.
A string is less than another if it comes before in the dictionary order.
A string is greater than another if it comes after in the dictionary order.
General form:
int compareTo(String str)
Here, str is the string being compared with the invoking string.
35. class SortStringFunc
{
static String arr[] = {"Now", "is", "the", "time", "for", "all", "good", "men","to", "come", "to",
"the", "aid", "of", "their", "country" };
public static void main(String args[])
{
for(int j = 0; j < arr.length; j++)
{
for(int i = j + 1; i < arr.length; i++)
{
if(arr[i].compareTo(arr[j]) < 0)
{
String t = arr[j];
arr[j] = arr[i];
arr[i] = t;
}
}
System.out.println(arr[j]);
}
}
}
Output:
Now
aid
all
come
country
for
good
is
men
of
the
the
their
time
to
to
36. 3. compareToIgnoreCase():
This method is the same as compareTo( ), but it ignores the lowercase and
uppercase differences of the strings while comparing.
37. Searching Strings
The Java String class provides two methods that allow us to search a
character or substring in another string.
• indexOf( ): It searches the first occurrence of a character or substring.
• lastIndexOf( ): It searches the last occurrence of a character or
substring.
38. class indexOfDemo
{
public static void main(String args[])
{
String s = "Now is the time for all good men " + "to come to the aid of their
country.";
System.out.println(s);
System.out.println("indexOf(t) = " + s.indexOf('t'));
System.out.println("lastIndexOf(t) = " + s.lastIndexOf('t'));
System.out.println("indexOf(the) = " + s.indexOf("the"));
System.out.println("lastIndexOf(the) = " + s.lastIndexOf("the"));
System.out.println("indexOf(t, 10) = " + s.indexOf('t', 10));
System.out.println("lastIndexOf(t, 60) = " + s.lastIndexOf('t', 60));
System.out.println("indexOf(the, 10) = " + s.indexOf("the", 10));
System.out.println("lastIndexOf(the, 60) = " + s.lastIndexOf("the", 60));
}
}
Output:
Now is the time for all good men to come to
their country.
indexOf(t) = 7
lastIndexOf(t) = 65
indexOf(the) = 7
lastIndexOf(the) = 55
indexOf(t, 10) = 11
lastIndexOf(t, 60) = 55
indexOf(the, 10) = 44
lastIndexOf(the, 60) = 55
40. 1. substring( )
• As the name suggests, ‘sub + string’, is a subset of a string. By subset, we
mean the contiguous part of a character array or string.
• The substring() method is used to fetch a substring from a string in Java.
General form:
• String substring(int startIndex)
• String substring(int startIndex, int endIndex)
• Here, startIndex specifies the beginning index, and endIndex specifies
the stopping point.
• The string returned contains all the characters from the beginning index,
up to, but not including, the ending index i.e [startindex,endindex-1]
41. / Substring replacement.
class StringReplace
{
public static void main(String args[])
{
String org = "This is a test. This is, too.";
String search = "is";
String sub = "was";
String result = "";
int i;
do {
// replace all matching substrings
System.out.println(org);
i = org.indexOf(search);
if(i != -1)
{
result = org.substring(0, i);
result = result + sub;
result = result + org.substring(i + search.length());
org = result;
}
} while(i != -1);
}
}
Output :
This is a test. This is, too.
Thwas is a test. This is, too.
Thwas was a test. This is, too.
Thwas was a test. Thwas is, too.
Thwas was a test. Thwas was, too.
42. 2. concat( )
• To concatenate two strings in Java, we can use the concat( ) method
apart from the “+” operator.
• General form:
• String concat(String str)
• This method creates a new object containing the invoking string with
the str appended to the end. This performs the same function as the +
operator. Refer to the comparison table below:
44. 3. replace( )
• This method is used to replace a character with some other character in a string. It has two forms.
• The first replaces all occurrences of one character in the invoking string with another character.
• General form:
• String replace(char original, char replacement)
• Here, the original specifies the character to be replaced by the character specified by replacement.
The resulting string is returned.
• For example:
String s = "Hello".replace('l', 'w’);
Result: s= “Hewwo”
45. 3. replace( )
• The second form replaces one character sequence with
another.
• General form:
• String replace(CharSequence original, CharSequence
replacement)
46. 4. trim( )
• The trim( ) method returns a copy of the invoking string from which any leading and trailing
whitespace has been removed.
General form:
• String trim( )
For example:
• String s = " Hello World ".trim();
• Result: s= “Hello World”
47. Data Conversion Using valueOf( )
• For converting different data types into strings, the valueOf() method is used. It is a static method
defined in the Java String class.
General form:
• static String valueOf(double num)
• static String valueOf(long num)
• static String valueOf(Object ob)
• static String valueOf(char chars[ ])
For example:
int num=20;
String s1=String.valueOf(num);
s1 = s1+10; //concatenating string s1 with 10
Result s1=2010
48. Changing the Case of Characters in a String
• The method toLowerCase( ) converts all the characters in a
string from uppercase to lowercase.
• The toUpperCase( ) method converts all the characters in a
string from lowercase to uppercase.
49. // Demonstrate toUpperCase() and toLowerCase().
class ChangeCase
{
public static void main(String args[])
{
String s = "This is a test.";
System.out.println("Original: " + s);
String upper = s.toUpperCase();
String lower = s.toLowerCase();
System.out.println("Uppercase: " + upper);
System.out.println("Lowercase: " + lower);
}
}
Output:
Original: This is a test.
Uppercase: THIS IS A TEST.
Lowercase: this is a test.
50. Joining strings
• In Java, you can join strings using the String.join() method. This method
allows you to concatenate multiple strings with a specified delimiter.
String fruits = String.join(" ", "Orange", "Apple", "Mango");
System.out.println(fruits);
The join() method takes two parameters.
delimiter - the delimiter to be joined with the elements
elements - elements to be joined
52. class Main {
public static void main(String[] args) {
String str1 = "I";
String str2 = "love";
String str3 = "Java";
// join strings with space between them
String joinedStr = String.join(" ", str1, str2, str3);
System.out.println(joinedStr);
}
}
// Output: I love Java
53. class Main {
public static void main(String[] args) {
String result;
result = String.join("-", "Java", "is", "fun");
System.out.println(result); // Java-is-fun
}
}
54. StringBuffer in Java
• StringBuffer is a class in the java.lang package that represents a mutable sequence
of characters.
• Unlike the String class, StringBuffer allows you to modify the content of the
string object after it has been created.
55. StringBuffer buffer = new StringBuffer("Hello, ");
buffer.append("World!"); // appends to the existing value
buffer.insert(7, "Java "); // inserts at a specified index
buffer.reverse(); // reverses the characters
System.out.println(buffer); // prints: "!dlroW avaJ ,olleH"
56. Key Features of StringBuffer
• Mutable: StringBuffer provides the flexibility to change the content, making it ideal
for scenarios where you have to modify strings frequently.
• Synchronized: Being thread-safe, it ensures that only one thread can access the
buffer's methods at a time, making it suitable for multi-threaded environments.
• Performance Efficient: For repeated string manipulation, using StringBuffer can be
more efficient than the String class.
• Method Availability: StringBuffer offers several methods to manipulate strings.
These include append(), insert(), delete(), reverse(), and replace().
57. When to Use StringBuffer?
• When you need to perform several modifications to strings,
using StringBuffer is an efficient choice.
• Due to the mutability of StringBuffer, it doesn't create a new object for every
modification, leading to less memory consumption and improved
performance.
• StringBuffer is especially beneficial in a multithreaded environment due to its
synchronized methods, ensuring thread safety
58. 1. append()
• The append() method adds the specified value to the end of the current
string.
StringBuffer buffer = new StringBuffer("javaguides");
buffer.append(" - For Beginners");
System.out.println(buffer);
// Output: "javaguides - For Beginners"
59. 2. insert()
• The insert() method adds the specified value at the given index.
import java.io.*;
class A {
public static void main(String args[])
{
StringBuffer sb = new StringBuffer("Hello ");
sb.insert(1, "Java");
// Now original string is changed
System.out.println(sb);
}
} Output
HJavaello
60. 3. delete()
• The delete() method of the StringBuffer class deletes the string from the specified
beginIndex to endIndex-1.
import java.io.*;
class A {
public static void main(String args[])
{
StringBuffer sb = new StringBuffer("Hello");
sb.delete(1, 3);
System.out.println(sb);
}}
Output
Hlo
61. 4.replace()
• The replace() method replaces the given string from the specified beginIndex and endIndex-1.
import java.io.*;
class A {
public static void main(String args[])
{
StringBuffer sb = new StringBuffer("Hello");
sb.replace(1, 3, "Java");
System.out.println(sb);
}
}
Output
HJavalo
62. 5.reverse()
• The reverse() method of the StringBuilder class reverses the current String.
class StringBufferExample5{
public static void main(String args[]){
StringBuffer sb=new StringBuffer("Hello");
sb.reverse();
System.out.println(sb);//prints olleH
}
}
63. 6.capacity()
• the capacity() method of the StringBuffer class returns the current capacity of the
buffer.
• The default capacity of the buffer is 16.
• If the number of character increases from its current capacity, it increases the
capacity by (oldcapacity*2)+2.
• For example if your current capacity is 16, it will be (16*2)+2=34.
64. class StringBufferExample6{
public static void main(String args[]){
StringBuffer sb=new StringBuffer();
System.out.println(sb.capacity());//default 16
sb.append("Hello");
System.out.println(sb.capacity());//now 16
sb.append("java is my favourite language");
System.out.println(sb.capacity());//now (16*2)+2=34 i.e (oldcapacity*2)+2
}
}
Output:
16
16
34
65. 7.ensureCapacity()
• The ensureCapacity() method of the StringBuffer class ensures that the
given capacity is the minimum to the current capacity.
• If it is greater than the current capacity, it increases the capacity by
(oldcapacity*2)+2. For example if your current capacity is 16, it will
be (16*2)+2=34.
66. class StringBufferExample7{
public static void main(String args[]){
StringBuffer sb=new StringBuffer();
System.out.println(sb.capacity());//default 16
sb.append("Hello");
System.out.println(sb.capacity());//now 16
sb.append("java is my favourite language");
System.out.println(sb.capacity());//now (16*2)+2=34 i.e (oldcapacity*2)+2
sb.ensureCapacity(10);//now no change
System.out.println(sb.capacity());//now 34
sb.ensureCapacity(50);//now (34*2)+2
System.out.println(sb.capacity());//now 70
}
}
Output:
16
16
34
34
70
67. Important Constructors of StringBuffer Class
Constructor with CharSequence
StringBuilder sb = new StringBuilder(CharSequence seq);
This constructor creates a StringBuilder instance that contains the same characters as the specified
CharSequence. Like the constructor with a string, the initial capacity will be the length of the CharSequence
plus 16.
68. public class StringBuilderExample {
public static void main(String[] args) {
// Default constructor
StringBuilder sb1 = new StringBuilder();
sb1.append("Hello, World!");
System.out.println(sb1);
// Constructor with initial capacity
StringBuilder sb2 = new StringBuilder(50);
sb2.append("Initial capacity set to 50.");
System.out.println(sb2);
// Constructor with initial string
StringBuilder sb3 = new StringBuilder("Initial String");
sb3.append(" appended text.");
System.out.println(sb3);
// Constructor with CharSequence
CharSequence seq = "CharSequence example";
StringBuilder sb4 = new StringBuilder(seq);
sb4.append(" additional text.");
System.out.println(sb4);
}
}
output
Hello, World!
Initial capacity set to 50.
Initial String appended text.
CharSequence example additional text.
69. String builder
• A StringBuilder is a mutable sequence of characters used in
programming languages such as Java, C#, and others.
• It is designed to efficiently handle strings that undergo multiple
modifications, such as concatenations, insertions, deletions, or
appending operations.
• Unlike immutable string objects, StringBuilder allows for these
operations without creating new string objects, making it more
performance-efficient, especially in scenarios involving extensive
string manipulation.
70. • append: Appends the specified data to the end of the StringBuilder.
sb.append("Hello");
sb.append(123);
sb.append(true);
insert: Inserts the specified data at the specified position.
sb.insert(0, "Start: ");
delete: Removes the characters in a substring of this sequence.
sb.delete(5, 10);
deleteCharAt: Removes the character at the specified position.
sb.deleteCharAt(0);
commonly used methods of StringBuilder:
71. replace: Replaces the characters in a substring of this sequence with characters in the specified
string.
sb.replace(0, 5, "Hi");
reverse: Reverses the sequence of characters.
sb.reverse();
toString: Converts the StringBuilder to a String.
String result = sb.toString();
setLength: Sets the length of the character sequence.
sb.setLength(10);
commonly used methods of StringBuilder:
72. public class StringBuilderExample {
public static void main(String[] args) {
// Default constructor
StringBuilder sb = new StringBuilder();
// Appending different types of data
sb.append("Hello, ");
sb.append("World!");
sb.append(" Number: ").append(42);
sb.append(" Boolean: ").append(true);
System.out.println(sb.toString());
// Inserting text
sb.insert(7, "Java ");
System.out.println(sb.toString());
// Deleting text
sb.delete(7, 12);
System.out.println(sb.toString());
// Replacing text
sb.replace(7, 12, "Universe");
System.out.println(sb.toString());
// Reversing the sequence
sb.reverse();
System.out.println(sb.toString());
// Converting to String
String result = sb.toString();
System.out.println("Final result: " + result);
}
}
OUTPUT
Hello, World! Number: 42 Boolean: true
Hello, Java World! Number: 42 Boolean: true
Hello, World! Number: 42 Boolean: true
Hello, Universe! Number: 42 Boolean: true
eurt :naelooB 24 :rebmuN !esrevinU ,olleH
Final result: eurt :naelooB 24 :rebmuN !esrevinU ,olleH