Programing with java for begniers .pptxadityaraj7711
Java is a high-level, object-oriented programming language developed by Sun Microsystems in the mid-1990s (now owned by Oracle Corporation). It is widely used for building a variety of applications, including desktop, web, mobile, and enterprise software. Java's design emphasizes portability, simplicity, and security, making it one of the most popular programming languages in the world.
### Importance of Java:
1. **Platform Independence**:
- Java programs can run on any device or operating system that supports the Java Virtual Machine (JVM).
- This "write once, run anywhere" (WORA) capability makes Java applications highly portable.
2. **Object-Oriented Programming (OOP)**:
- Java supports key OOP principles such as inheritance, encapsulation, polymorphism, and abstraction.
- These principles enable developers to create modular and reusable code.
3. **Rich Ecosystem and Libraries**:
- Java has a vast ecosystem of libraries, frameworks, and tools that facilitate development across various domains.
- Popular frameworks like Spring, Hibernate, and Apache Struts streamline development in enterprise environments.
4. **Robustness and Reliability**:
- Java has strong exception handling and type-checking mechanisms that contribute to the robustness and reliability of applications.
5. **Community and Support**:
- Java has a large and active developer community, providing support and resources for learning and troubleshooting.
- Java's extensive documentation and community forums are valuable resources for developers.
6. **Performance**:
- Java's just-in-time (JIT) compilation allows for optimized execution, improving performance.
- Java can handle large-scale applications and complex computations efficiently.
7. **Security**:
- Java's architecture includes features such as runtime security checks and a security manager for safe execution.
- This makes it a preferred choice for developing secure applications.
8. **Enterprise Applications**:
- Java is a dominant language in enterprise development due to its scalability, stability, and compatibility with existing systems.
- Many businesses rely on Java for mission-critical applications.
9. **Career Opportunities**:
- Proficiency in Java opens up many career opportunities, particularly in enterprise development, finance, healthcare, and telecommunications.
10. **Future-Proofing**:
- Java's continuous updates and compatibility with emerging technologies ensure that it remains relevant and future-proof.
Overall, Java's versatility, reliability, and widespread adoption make it an essential language for developers across various industries
,,,,,,jhbhhhhhvggvvcccccccfghhhhhhhhhhhhhgggggggggyyyyy hhbbhhhhgggyhhsyddhdhhddhsiejdhajshdhdhdhdhdhdudufjdhyeyeg hhdhdhdhdhdhdhdhdh d bhsuhabuesjjsoeijshshdhsjajsijehfdhhdhdhdhdhhdxbbxxhxhhdja hi in najajajhwhr7fhhhhhhhhhhhhhhhhhuhhuwbshdhhddh8rhedi8fnf
Programing with java for begniers .pptxadityaraj7711
Java is a high-level, object-oriented programming language developed by Sun Microsystems in the mid-1990s (now owned by Oracle Corporation). It is widely used for building a variety of applications, including desktop, web, mobile, and enterprise software. Java's design emphasizes portability, simplicity, and security, making it one of the most popular programming languages in the world.
### Importance of Java:
1. **Platform Independence**:
- Java programs can run on any device or operating system that supports the Java Virtual Machine (JVM).
- This "write once, run anywhere" (WORA) capability makes Java applications highly portable.
2. **Object-Oriented Programming (OOP)**:
- Java supports key OOP principles such as inheritance, encapsulation, polymorphism, and abstraction.
- These principles enable developers to create modular and reusable code.
3. **Rich Ecosystem and Libraries**:
- Java has a vast ecosystem of libraries, frameworks, and tools that facilitate development across various domains.
- Popular frameworks like Spring, Hibernate, and Apache Struts streamline development in enterprise environments.
4. **Robustness and Reliability**:
- Java has strong exception handling and type-checking mechanisms that contribute to the robustness and reliability of applications.
5. **Community and Support**:
- Java has a large and active developer community, providing support and resources for learning and troubleshooting.
- Java's extensive documentation and community forums are valuable resources for developers.
6. **Performance**:
- Java's just-in-time (JIT) compilation allows for optimized execution, improving performance.
- Java can handle large-scale applications and complex computations efficiently.
7. **Security**:
- Java's architecture includes features such as runtime security checks and a security manager for safe execution.
- This makes it a preferred choice for developing secure applications.
8. **Enterprise Applications**:
- Java is a dominant language in enterprise development due to its scalability, stability, and compatibility with existing systems.
- Many businesses rely on Java for mission-critical applications.
9. **Career Opportunities**:
- Proficiency in Java opens up many career opportunities, particularly in enterprise development, finance, healthcare, and telecommunications.
10. **Future-Proofing**:
- Java's continuous updates and compatibility with emerging technologies ensure that it remains relevant and future-proof.
Overall, Java's versatility, reliability, and widespread adoption make it an essential language for developers across various industries
,,,,,,jhbhhhhhvggvvcccccccfghhhhhhhhhhhhhgggggggggyyyyy hhbbhhhhgggyhhsyddhdhhddhsiejdhajshdhdhdhdhdhdudufjdhyeyeg hhdhdhdhdhdhdhdhdh d bhsuhabuesjjsoeijshshdhsjajsijehfdhhdhdhdhdhhdxbbxxhxhhdja hi in najajajhwhr7fhhhhhhhhhhhhhhhhhuhhuwbshdhhddh8rhedi8fnf
A string buffer implements a mutable sequence of characters.
A string buffer is like a String, but can be modified.
At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.
Every string buffer has a capacity.
When the length of the character sequence contained in the string buffer exceed the capacity, it is automatically made larger.
String Handling, Inheritance, Packages and InterfacesPrabu U
The presentation starts with string handling. Then the concepts of inheritance is detailed. Finally the concepts of packages and interfaces are detailed.
In this chapter we will explore strings. We are going to explain how they are implemented in C# and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions. We will discuss some classes for efficient construction of strings. Finally, we will take a look at the methods and classes for achieving more elegant and stricter formatting of the text content.
A string buffer implements a mutable sequence of characters.
A string buffer is like a String, but can be modified.
At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.
Every string buffer has a capacity.
When the length of the character sequence contained in the string buffer exceed the capacity, it is automatically made larger.
String Handling, Inheritance, Packages and InterfacesPrabu U
The presentation starts with string handling. Then the concepts of inheritance is detailed. Finally the concepts of packages and interfaces are detailed.
In this chapter we will explore strings. We are going to explain how they are implemented in C# and in what way we can process text content. Additionally, we will go through different methods for manipulating a text: we will learn how to compare strings, how to search for substrings, how to extract substrings upon previously settled parameters and last but not least how to split a string by separator chars. We will demonstrate how to correctly build strings with the StringBuilder class. We will provide a short but very useful information for the most commonly used regular expressions. We will discuss some classes for efficient construction of strings. Finally, we will take a look at the methods and classes for achieving more elegant and stricter formatting of the text content.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
Power-sharing Class 10 is a vital aspect of democratic governance. It refers to the distribution of power among different organs of government, levels of government, and social groups. This ensures that no single entity can control all aspects of governance, promoting stability and unity in a diverse society.
For more information, visit-www.vavaclasses.com
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
2. • The Java platform contains three classes
1. Character: - A class whose instances can hold a single
character value
2. String: - A class for working with immutable
(unchanging) data composed of multiple characters
3. StringBuffer: - A class for storing and manipulating
mutable data composed of multiple characters.
• Character
– use a Character object instead of a primitive char variable
when an object is required
– For example, when passing a character value into a
method
3. public class CharacterDemo {
public static void main(String args[]) {
Character a = new Character('A');
Character a2 = new Character('a');
Character b = new Character('b');
int difference = a.compareTo(b);
if (difference == 0) {
System.out.println(a+ " is equal to "+ b);
}
else if (difference <0)
System.out.println(a+" is less than "+b );
else
System.out.println(a+" is greater than "+b);
4. System.out.println(a+" is " + ((a.equals(a2)) ? "equal" : "not
equal") + " to "+a2);
System.out.println("The character " + a.toString() + " is " +
(Character.isUpperCase(a.charValue()) ? "upper" :
"lower") + "case.");
}
}
• Output
– A is less than b
– A is not equal to a
– The character A is uppercase.
5. Character Class
• Constant
– public static final int MAX_RADIX = 36
– public static final char MAX_VALUE =‘ffff’
– public static final int MIN_RADIX = 2
– public static final char MIN_VALUE =’0000’
• Method
– Character(char value) : Constructor to initialize the
object as value
– char charValue() : Convert into char type
– static boolean isDigit(char ch) : Test whether is digit?
– static boolean isLetter(char ch) : Test whether is letter?
– static boolean isLetterOrDigit(char ch) : Return when it
is letter or digit.
6. • String
– In Java a string is a sequence of characters
– Java implements strings as objects of type String.
– objects of type String are immutable;
– once a String object is created, its contents cannot be altered
– If you want to change String object
• create a new string that contains the modifications.
• Use StringBuffer class
– Strings can be constructed a variety of ways.
• use a statement like:
String myString = "this is a test";
• using the new keyword and a constructor
– For example: String str = new String (charArray);
– Both String and StringBuffer are declared final, which
means that neither of these classes may be subclassed.
7. • Strings are immutable
class String Test{
public static void main(String args[]){
String name = “Kebede”;
System.out.println(name);
name = name + “Tollosa”;
System.out.println(name);
}
}
• OutPut:
Kebede
Kebede Tollosa
Memory
name Kebede
Kebede Tollosa
8. The String Constructors
• The String class supports several constructors.
String s = new String();
– To create a String initialized by an array of characters, use the
constructor
String(char chars[ ])
– example:
char chars[] = { 'a', 'b', 'c' };
String s = new String(chars);
– This constructor initializes s with the string "abc".
– You can specify a sub-range of a character array as an
initializer using the following constructor:
String(char chars[ ], int startIndex, int numChars)
– startIndex specifies the index at which the subrange begins,
and numChars specifies the number of characters to use
9. – example:
char chars[] = { 'a', 'b', 'c', 'd', 'e', 'f' };
String s = new String(chars, 2, 3);
– This initializes s with the characters cde.
– You can construct a String object that contains the same
character sequence as another String object using this
constructor:
String(String strObj)
– example:
class MakeString {
public static void main(String args[]) {
char c[] = {'J', 'a', 'v', 'a'};
String s1 = new String(c);
String s2 = new String(s1);
System.out.println(s1);
System.out.println(s2);
} }
10. – The output from this program is as follows:
Java
Java
– The following program converts the given byte array into
String
// Construct string from subset of char array.
class SubStringCons {
public static void main(String args[]) {
byte ascii[] = {65, 66, 67, 68, 69, 70 };
String s1 = new String(ascii);
System.out.println(s1);
String s2 = new String(ascii, 2, 3);
System.out.println(s2);
} }
– This program generates the following output:
ABCDEF
CDE
11. String Class
• Method
– char charAt(int index) :
• Return the character at specific position in string
– int length() :
• Return the length of string
– String toUpperCase() :
• Convert the string into upper character
– String toLowerCase() :
• Convert the string into lower character
– void getChars() :
• extract more than one character at a time
– String substring(int beginIndex) :
• Make the sub string from beginIndex to the end of the
string
12. • getChars( )
– extract more than one character at a time
– general form:
void getChars(int Start, int End, char target[ ], int targetStart)
– Start specifies the index of the beginning of the substring,
– End specifies an index that is one past the end of the desired
substring
– The array that will receive the characters is specified by target.
– The index within target at which the substring will be copied is
passed in targetStart
13. – The following program demonstrates getChars( ):
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);
}
}
– Here is the output of this program:
demo
14. • String Concatenation
– + operator
– Example:
String age = "9";
String s = "He is " + age + " years old.";
System.out.println(s);
• String Concatenation with Other Data Types
int age = 9;
String s = "He is " + age + " years old.";
System.out.println(s);
– The compiler will convert an operand to its string equivalent
whenever the other operand of the + is an instance of String.
15. – Consider the following:
String s = "four: " + 2 + 2;
System.out.println(s);
– This fragment displays
four: 22
– To complete the integer addition first, you must use
parentheses, like this:
String s = "four: " + (2 + 2);
– Now s contains the string "four: 4".
• You can concatenate two strings using concat( )
String concat(String str)
String s1 = "one";
String s2 = s1.concat("two");
16. • String Conversion and toString( )
– Java converts data into its string representation during
concatenation by
• calling one of the string conversion method valueOf( )
• valueOf( ) is overloaded for all the simple types and for type
Object
– For the simple types, valueOf( ) returns a string that contains
the human-readable equivalent of the value with which it is
called.
– For objects, valueOf( ) calls the toString( ) method on the
object
– Every class implements toString( ) because it is defined by
Object
– The toString( ) method has this general form:
String toString( )
17. • The following program demonstrates overriding toString( )
for the Box class:
// Override toString() for Box class.
class Box {
double width, height, depth;
Box(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
public String toString() {
return "Dimensions are " + width + " by " + depth + " by "
+ height + ".";
}
}
18. class toStringDemo {
public static void main(String args[]) {
Box b = new Box (10, 12, 14);
String s = "Box b: " + b; // concatenate Box object
System.out.println (b); // convert Box to string
System.out.println (s);
}
}
– The output of this program is shown here:
Dimensions are 10 by 14 by 12.
Box b: Dimensions are 10 by 14 by 12
20. • Searching Strings
– The String class provides two methods that allow you to
search a string for a specified character or substring:
– indexOf( ) Searches for the first occurrence of a character or
substring.
– lastIndexOf( ) Searches for the last occurrence of a character
or substring.
– To search for the first or last occurrence of a substring, use
int indexOf(String str)
int lastIndexOf(String str)
– str specifies the substring
– You can specify a starting point for the search using these
forms:
int indexOf(chae ch, int startIndex)
int lastIndexOf(char ch, int startIndex)
int indexOf(String str, int startIndex)
int lastIndexOf(String str, int startIndex)
21. • For indexOf( ), the search runs from startIndex to the end of
the string.
• For lastIndexOf( ), the search runs from startIndex to zero.
// Demonstrate indexOf() and lastIndexOf().
class indexOfDemo {
public static void main(String args[]) {
String s = "Now is the time for all good persons" + "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"));
22. 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));
}
}
– the output of this program:
Now is the time for all good men to come to the aid of their country.
• Now is the time for all good personsto come to the aid of
their country.
indexOf(t) = 7 lastIndexOf(t) = 68
indexOf(the) = 7 lastIndexOf(the) = 58
indexOf(t, 10) = 11 lastIndexOf(t, 60) = 58
indexOf(the, 10) = 47 lastIndexOf(the, 60)=58
23. • Modifying a String
– to modify a String, you must either copy it into a
StringBuffer or use one of the following String methods,
– substring( )
• It has two forms.
1. String substring(int startIndex)
2. String substring(int startIndex, int endIndex)
• The string returned contains all the characters from the
beginning index, up to, but not including, the ending index.
24. // 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;
25. result = result + org.substring(i + search.length());
org = result;
}//end of if
} while(i != -1);
}
}
• The 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.
26. Exercise
• Write a program that performs the following
– Accepts a string
– converts it into Uppercase or Lowercase
– extract substring based on the users interest.
– Search a Palindrome word within the given string.
– counts the number of words
– Extract the special characters
27. StringBuffer Class
• is a peer class of String
• represents growable and writeable character sequences.
• will automatically grow to make room for such additions
• often has more characters pre-allocated than are actually
needed, to allow room for growth.
– for example, when reading text data from a file.
• may have characters and substrings inserted in the middle or
appended to the end.
• StringBuffer defines these three constructors:
– StringBuffer( )
– StringBuffer(int size)
– StringBuffer(String str)
28. • The default constructor (the one with no parameters)
reserves room for 16 characters without reallocation.
• The second version accepts an integer argument that
explicitly sets the size of the buffer.
• The third version accepts a String argument that sets the
initial contents of the StringBuffer object and reserves room
for 16 more characters without reallocation.
• By allocating room for a few extra characters, StringBuffer
reduces the number of reallocations that take place.
29. • length( ) and capacity( )
– The current length of a StringBuffer can be found via the
length( ) method
– The total allocated capacity can be found through the
capacity( ) method.
• Here is an example:
// StringBuffer length
class StringBufferDemo1 {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("Hello");
System.out.println("buffer = " + sb);
System.out.println("length = " + sb.length());
System.out.println("Capacity= "+ sb.capacity());
} }
• Output: buffer = Hello
length = 5 Capacity = 21
30. • append( )
– The append() method concatenates the string representation of
any other type of data to the end of the invoking StringBuffer
object
– few of its forms:
StringBuffer append(String str)
StringBuffer append(int num)
StringBuffer append(Object obj)
31. // Demonstrate append().
class appendDemo {
public static void main(String args[]) {
String s;
int a = 42;
StringBuffer sb = new StringBuffer(40);
s = sb.append("a = ").append(a).append("!").toString();
System.out.println(s);
}
}
• The output of this example is shown here:
a = 42!
32. • insert( )
– The insert( ) method inserts one string into another
– few of its forms:
StringBuffer insert(int index, String str)
StringBuffer insert(int index, char ch)
StringBuffer insert(int index, Object obj)
// Demonstrate insert().
class insertDemo {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("I Java!");
sb.insert(2, "like ");
System.out.println(sb);
}
}
– The output
I like Java!
33. • reverse( )
StringBuffer reverse( )
// Using reverse() to reverse a StringBuffer.
class ReverseDemo {
public static void main(String args[]) {
StringBuffer s = new StringBuffer("abcdef");
System.out.println(s);
s.reverse();
System.out.println(s);
}
}
– the output:
abcdef
fedcba
34. • delete( ) and deleteCharAt( )
– The delete( ) method deletes a sequence of characters from the
invoking object.
StringBuffer delete(int startIndex, int endIndex)
– startIndex specifies the index of the first character to remove,
and endIndex specifies an index one past the last character to
remove.
– the substring deleted runs from startIndex to endIndex–1.
StringBuffer deleteCharAt(int loc)
– deletes the character at the index specified by loc.
35. // Demonstrate delete() and deleteCharAt()
class deleteDemo {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("This is a test.");
sb.delete(4, 7);
System.out.println("After delete: " + sb);
sb.deleteCharAt(0);
System.out.println("After deleteCharAt: " + sb);
}
}
– The output:
After delete: This a test.
After deleteCharAt: his a test.
36. • replace( )
– replaces one set of characters with another set inside a
StringBuffer object.
StringBuffer replace(int startIndex, int endIndex, String str)
// Demonstrate replace()
class replaceDemo {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("This is a test.");
sb.replace(5, 7, "was");
System.out.println("After replace: " + sb);
}
}
– The output:
After replace: This was a test.
37. StringBuffer Class
String now = new java.util.Date().toString();
StringBuffer strbuf = new StringBuffer(now);
strbuf.append(" : ").append(now.length()).append('.');
System.out.println(strbuf.toString());