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>
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
This is First Lecture of java Programming which cover all basic points (ie. History and feature of java, Introduction to java, about variables data type and compilation....
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
This is First Lecture of java Programming which cover all basic points (ie. History and feature of java, Introduction to java, about variables data type and compilation....
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
In this core java training session, you will learn Elements of Java programming. Topics covered in this session are:
• Quick review of some important concepts from last class
• History of Java
• JDK and JRE
• Byte Code and JVM (Java Virtual Machine)
• Platform Independence
• Principles of Object Oriented Programming
• Writing your first Java Application
• Elements of Java programming language
• Built in Data Types
• Conditional Statements
• Loops
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
In this core java training session, you will learn Handling Arrays in Java. Topics covered in this session are:
• Autoboxing and Unboxing in Java
• Handling Arrays
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
This extensive course covers all the topics which will definitely make you a Java Superstar. You can do almost anything in Java after this course. You will surely be a better programmer and better still a Elegant programmer after this course.
OOPS Concepts, Java Evolution, Class Object basic, Class Object Constructor overloading, Inheritance, Array and String, Final Abstract class and interfaces, Exceptions, Streams, GUI Applications, Applet Programming, Network Programming and Java Sockets, Multi Threading
This ppt tells about what is Java? What are the requirements of Java? And how it works? For more info about Java and free Java Projects Visit : http://s4al.com/category/study-java/
Mahika Tutorials sharing PPT slide for core java programming language. Go threw this slide and visit our YouTube page too
https://www.youtube.com/c/mahikatutorials
This Edureka Java Tutorial will help you in understanding the various fundamentals of Java in detail with examples. Below are the topics covered in this tutorial:
1) Introduction to Java
2) Why learn Java?
3) Features of Java
4) How does Java work?
5) Data types in Java
6) Operators in Java
7) Control Statements in Java
8) Arrays in Java
9) Object Oriented Concepts in Java
Here I discuss about Java programming language and easiest way to solve programming problem. Java basic syntax and their uses are described briefly so that anyone can easily understand within very short time. If anyone follow the slide with proper way,I assure that he or she will find java programming interesting.
In this core java training session, you will learn Elements of Java programming. Topics covered in this session are:
• Quick review of some important concepts from last class
• History of Java
• JDK and JRE
• Byte Code and JVM (Java Virtual Machine)
• Platform Independence
• Principles of Object Oriented Programming
• Writing your first Java Application
• Elements of Java programming language
• Built in Data Types
• Conditional Statements
• Loops
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
In this core java training session, you will learn Handling Arrays in Java. Topics covered in this session are:
• Autoboxing and Unboxing in Java
• Handling Arrays
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
This extensive course covers all the topics which will definitely make you a Java Superstar. You can do almost anything in Java after this course. You will surely be a better programmer and better still a Elegant programmer after this course.
OOPS Concepts, Java Evolution, Class Object basic, Class Object Constructor overloading, Inheritance, Array and String, Final Abstract class and interfaces, Exceptions, Streams, GUI Applications, Applet Programming, Network Programming and Java Sockets, Multi Threading
This ppt tells about what is Java? What are the requirements of Java? And how it works? For more info about Java and free Java Projects Visit : http://s4al.com/category/study-java/
Mahika Tutorials sharing PPT slide for core java programming language. Go threw this slide and visit our YouTube page too
https://www.youtube.com/c/mahikatutorials
This Edureka Java Tutorial will help you in understanding the various fundamentals of Java in detail with examples. Below are the topics covered in this tutorial:
1) Introduction to Java
2) Why learn Java?
3) Features of Java
4) How does Java work?
5) Data types in Java
6) Operators in Java
7) Control Statements in Java
8) Arrays in Java
9) Object Oriented Concepts in Java
What is Java Technology (An introduction with comparision of .net coding)Shaharyar khan
A introductory slides for those who want to learn and know some basics of Java.Also for those persons who want to compare coding difference between Java and .net
This is a beginner-level programming session where you will learn the fundamentals of Java. Between each lesson, you'll have skill testing in the form of quizzes, as well as hands-on experience in the field.
Miller Columns (used in iPhone and Mac Finder) are an elegant way of displaying and navigating a tree. This talk describes a JavaScript implementation of Miller Columns, and why JavaScript needs modules and a standard library.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
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
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
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.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
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. Slide 2
● Introduction to Java
● Features of Java
● Evolution of Java
● Developing software in Java
● Writing, Compiling and execution of Simple Java Program
● Java Language Fundamentals
Lesson Objective
3. Slide 3
● History of Java :
Developed: 1991 - Part of Sun's "Green Team Project
Created by: Patrick Naughton, Mike Sheridan, and James Gosling
Demo released: 1992
Released: 1995
Original name: Oak
● Recent News:
* 2006 – Sun released much of java as open source software
* 2009 – 2010 – Oracle corporation acquired Sun Microsystems
● About Java Technology:
Java is a high level programming language created by Sun Microsystems.
Java technology is both a programming language and a platform
Introduction to Java
4. Slide 4
● Object Oriented : class, object, inheritance, polymorphism … etc
● Simple : easy to learn
● Robust : strongly typed
● Secure : Byte code verifier, Security Manager …etc.
● Architecture Neutral: Platform independent
● Interpreted and Compiled
● Multithreaded: Concurrent running tasks
● Dynamic : run time linking of code [applet]
● Memory Management and Garbage Collection
Features of Java
5. Slide 5
● Java Development Kit(JDK)
The Java Developer’s Kit is distributed by Sun Microsystems. The JDK
contains documentation, examples, installation instructions, class
libraries packages and tools.
There are two installers available.
● JDK – Software development Kit – compile and run java program
● JRE – Java Runtime Environment – run java program [subset of JDK ]
● How to Install Java?
● Download the latest Java Installable from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
● Java Virtual Machine (JVM) : Platform Independent
Developing software in Java
6. Slide 6
● Java Virtual Machine (JVM)
● Java VM is available on many different operating systems. Hence the same
.class files can be run on Microsoft Windows, the Solaris TM Operating System
(Solaris OS), Linux, or Mac OS.
Writing, Compiling and Execution of Java Program
7. Slide 7
● A Java program is written, compiled and executed in three steps.
● Step – 1: The source code is written in plain text file ending with .java
extension.
● Step – 2 : The source files are compiled into .class files using javac compiler.
● Step – 3: The java launcher tool runs the application with an instance of JVM -
Java Virtual Machine.
Writing, Compiling and Execution of Java Program
8. Slide 8
● A Simple Java Program
class ExampleProgram {
public static void main(String[] args){
System.out.println("I'm a Simple Program");
}
}
● Compiling the Program
javac ExampleProgram.java
● Interpreting and Running the Program
Once the program successfully compiles into Java bytecodes, the
Java interpreter is invoked at the command line on Unix and DOS shell
operating systems as follows:
java ExampleProgram
● Output : I'm a Simple Program
Writing, Compiling and Execution of Java Program
9. Slide 9
● Java Comments
● Single line Comment // comment statement
● Multiline Comment /* comment statement 1
comment statement 2
*/
Java Language Fundamentals
/* This Java class example describes how class is defined and being used in
Java language.
*/
public class JavaClassExample {
//main method – Entry Point
public static void main(String args[]){
//method call
System.out.println(“Hello World”);
}
}
OUTPUT : Hello World
10. Slide 10
Java Comments
● Comments :
Comments are descriptions that are added to a program to make code
easier to understand. The compiler ignores comments and hence its only for
documentation of the program. Java supports three comment styles.
● Implementation Comments:
Line style comments - begin with // and terminate at the end of the line.
Block style comments - begin with /* and terminate with */ that spans multiple
lines.
● Documentation comments
Begin with /** and terminate with */ that spans multiple lines. They
are generally created using the automatic documentation generation tool,
such as javadoc.
11. Slide 11
Type Size/Format Description
byte 8-bit Byte-length integer
short 16-bit Short Integer
int 32-bit Integer
long 64-bit Long Integer
float 32-bit IEEE 754 Single precision floating point
double 64-bit IEE 754 Double precision floating point
char 16-bit A single character
boolean 1-bit True or False
Data Types
● Variables have a data type, that indicates the kind of value they
can store.
12. Slide 12
● Basic storage in a Java program
● Three types of variables:
● Instance variables
Instantiated for every object of the class.
● Static variables
Class Variables
Not instantiated for every object of the class.
● Local variables
Declared in methods and blocks.
● Formal Parameters: Arguments passed to a function.
Types of Variables
13. Slide 13
class emp {
String name; //Instance Variable
int empcode; //Instance Variable
float basicsalary; //Instance Variable
static int obcount; //static variable
void calculateSalary() {
float temp sal; //Local variable
….
}
} //class emp ends
Types of Variables
14. Slide 14
● Parameters or arguments passed to a function are
passed by value for primitive data-types.
● Parameters or arguments passed to a function are passed by
reference for non-primitive data-types
● Example: All Java objects.
Methods and Parameter Passing
void myFunction(Integer a) {
a++;
System.out.println(a);
}
….
Integer x = 45;
System.out.println(x);
myFunction(x);
System.out.println(x);
Output is, “45 46 45”
void myFunction(int a) {
a++;
System.out.println(a);
}
….
int x = 45;
System.out.println(x);
myFunction(x);
System.out.println(x);
Output is, “45 46 45”
15. Slide 15
● New feature added in J2SE5.0.
● Allows methods to receive unspecified number of arguments.
● An argument type followed by ellipsis(…) indicates variable number
of arguments of a particular type.
● Variable-length argument can take from zero to n arguments.
● Ellipsis can be used only once in the parameter list.
● Ellipsis must be placed at the end of the parameter list.
Variable Argument List
16. Slide 16
● Valid Code
void print(int a,int y,String...s)
{
//code
}
print(1,1,”XYZ”) or print(2,5) or print(5,6,”A”,”B”) invokes
the above print function
● Invalid Code
void print(int a, int b…,float c)
{
//code
}
Variable Argument List
18. Slide 18
Keywords in Java
* not used *** added in 1.4
** added in 1.2 **** added in 5.0
● Keywords are reserved words can’t be used as variables, function
and class names.
19. Slide 19
● Operators can be divided into following groups:
● Arithmetic
● Bitwise
● Relational
● Logical
● instanceOf Operator
Operators and Assignments Java
24. Slide 24
● The instanceof operator compares an object to a specified
type
● Checks whether an object is:
● An instance of a class.
● An instance of a subclass.
● An instance of a class that implements a particular interface.
● The following returns true:
new String("Hello") instanceof String;
instanceOf Operators
25. Slide 25
● Use control flow statements to:
● Conditionally execute statements.
● Repeatedly execute a block of statements.
● Change the normal, sequential flow of control.
● Categorized into two types:
● Selection Statements
● Iteration Statements
Control Statements
26. Slide 26
● Allows programs to choose between alternate actions on execution.
● “If” used for conditional branch:
if (condition) statement1;
else statement2;
● “Switch” used as an alternative to multiple “if’s”:
switch(expression){
case value1: //statement sequence
break;
case value2: //statement sequence
break; …
default: //default statement sequence
}
Selection Statements
27. Slide 27
● Allow a block of statements to execute repeatedly.
● While Loop:
● Enters the loop if the condition is true.
while (condition)
{ //body of loop }
● Do – While Loop:
● Loop executes at least once even if the condition is false.
do
{ //body of the loop
} while(condition)
● For Loop: for( initialization ; condition ; iteration)
{ //body of the loop }
Iteration Statements
28. Slide 28
● New feature introduced in Java 5.
● Iterate through a collection or array.
● Syntax:
for (variable : collection)
{ //code}
● Example
int sum(int[] a)
{
int result = 0;
for (int i : a)
result += i;
return result; }
Enhanced for Loop (foreach)
29. Slide 29
● Classes:
● A template for multiple objects with similar features.
● A blueprint or the definition of objects.
class < class_name>
{
type var1; …
Type method_name(arguments )
{
body
} …
} //class ends
● Objects:
● Instance of a class.
● Concrete representation of class.
Objects and Classes
31. Slide 31
Declaring Objects
● Code Snippet
class Impl{
public static void main(String a[])
{
//declare a reference to object
Box b;
//allocate a memory for box object.
b = new Box();
// call a method on that object.
b.volume();
}
}
32. Slide 32
● A Java package is a set of classes which are grouped together.
● To organize Java classes
● To code multiple Java classes with the same name.
● Using Java Packages :
To use a package in your Java source code, you must either import
the package or use the fully qualified class name each time you
use a class.
● Importing Classes :
import java.util.Date;
Or
Java.util.Date d = new java.util.Date();
All the classes in Java.lang package are automatically imported when
the program runs. The rest of other classes in the packages are to
be imported by the programmer by using the import keyword.
Packages in Java
34. Slide 34
Constructors
● Constructors are similar to methods except that constructors have the same name
as the class . When a new instance (a new object) of a class is created using the
new keyword, the constructor for that class is called. Constructors are used to
initialize the instance variables (fields) of an object.
● Default constructor. If we don't define a constructor for a class, a default
parameterless constructor is automatically created by the compiler. The default
constructor calls the default parent constructor (super()) and initializes all instance
variables to default value (zero for numeric types, null for object references, and
false for booleans).
● Default constructor is created only if there are no constructors. If you define
any constructor for your class, no default constructor is automatically created.
● Differences between methods and constructors.
● Constructor does not have a return type
● There is no return statement in the body of the constructor.
● The first line of a constructor must either be a call on another constructor in
the same class (using this), or a call on the superclass constructor (using
super). If the first line is neither of these, the compiler automatically inserts a
call to the parameterless super class constructor.
35. Slide 35
Constructor – Example program
Example of explicit this constructor call
public class Point {
int m_x;
int m_y;
//============ Constructor public
Point(int x, int y) {
m_x = x;
m_y = y;
}
//============ Parameterless default constructor
public Point() {
this(0, 0);
// Calls other constructor.
}
. . . }
36. Slide 36
Types of Class Members
● Default access members (No access specifier)
● accessible only by classes in the same package
● Private members
● cannot be accesses by anywhere outside the enclosing class
● Public members
● are visible to any class in the Java program, whether these classes
are in the same package or in another package.
● Protected member
● only accessible by subclasses in same aa well as other packages
37. Slide 37
● Dynamic and Automatic
● No Delete operator
● Java Virtual Machine (JVM) de-allocates memory allocated to
unreferenced objects during the garbage collection process.
Memory Management
38. Slide 38
● Garbage Collector:
● Lowest Priority Daemon Thread
● Runs in the background when JVM starts.
● Collects all the unreferenced objects.
● Frees the space occupied by these objects.
● Call System.gc() method to “hint” the JVM to invoke the garbage
collector.
There is no guarantee that it would be invoked. It is implementation
dependent.
Enhancement in Garbage Collector
39. Slide 39
● All Java classes have constructors.
● Constructors initialize a new object of that type.
● Default no-argument constructor is provided if program has no
constructors.
● Constructors:
Same name as the class.
No return type; not even void.
Memory Management
40. Slide 40
● Memory is automatically de-allocated in Java.
● Invoke finalize() to perform some housekeeping tasks before an
object is garbage collected.
● Invoked just before the garbage collector runs:
● protected void finalize()
Finalize() Method
41. Slide 41
● A group of like-typed variables referred by a common name.
● Array declaration:
● int arr [];
arr = new int[10]
● int arr[] = {2,3,4,5};
● int two_d[][] = new int[4][5];
Arrays
42. Slide 42
● Arrays of objects too can be created:
● Example 1:
Box Barr[] = new Box[3];
Barr[0] = new Box();
Barr[1] = new Box();
Barr[2] = new Box();
● Example 2:
String[] Words = new String[2];
Words[0]=new String(“Bombay”);
Words[1]=new String(“Pune”);
Creating Array Objects
43. Slide 43
● Arrays of objects too can be created:
● Example 1:
Box Barr[] = new Box[3];
Barr[0] = new Box();
Barr[1] = new Box();
Barr[2] = new Box();
● Example 2:
String[] Words = new String[2];
Words[0]=new String(“Bombay”);
Words[1]=new String(“Pune”);
Creating Array Objects
45. Slide 45
Static variable
● Static variable is shared by all the class members.
● Used independently of objects of that class.
● Static members can be accessed before an object of a class is
created, by using the class name:
●Example:
static int intNum1 = 3;
46. Slide 46
4646
Static Methods
● Restrictions:
●Can only call other static methods.
●Must only access other static data.
●Cannot refer to this or super in any way.
●Can not access non-static variables and methods directly:
Explicit instance variables should be made available to the method.
Method main() is a static method. It is called by JVM.
47. Slide 47
● Cosmic super class.
● Ultimate ancestor
● Every class in Java implicitly extends Object.
● Object type variables can refer to objects of any type:
● Example:
Object obj = new Emp();
● Object Class Methods:
● void finalize()
● Class getClass()
● String toString()
The Object Class
49. Slide 49
● Used to interact with any of the system resources.
● Cannot be instantiated.
● Contains a methods and variables to handle system I/O.
● Facilities provided by the System class:
● Standard input
● Standard output
● Error output streams
The System Class
52. Slide 52
● String is handled as an object of class String and not as an array of
characters.
● String class is a better and a convenient way to handle any
operation.
● One main restriction is that once an object of this class is created,
the contents cannot be changed.
String Handling
53. Slide 53
String Handling – Important Methods
● length(): length of string.
● indexOf(): searches an occurrence of a char, or string within other
string.
● substring(): Retrieves substring from the object.
● trim(): Removes spaces.
● valueOf(): Converts data to string.
54. Slide 54
The String Class
str1
String str = new String(“Pooja”);
String str1 = new String(“Sam”);
Pooja
Sam
str
str1
String str = new String(“Pooja”);
String str1 = str;
Pooja str
Heap Stack
55. Slide 55
● Use a “+” sign to concatenate two strings:
● String Subject = "Core " + "Java"; -> Core Java
● String concatenation operator if one operand is a string:
String a = "String"; int b = 3; int c=7
System.out.println(a + b + c); -> String37
● Addition operator if both operands are numbers:
System.out.println(a + (b + c)); -> String10
String Concatenation
56. Slide 56
● public String concat(String s)
● Used to concatenate a string to an existing string.
● String x = "Core ";
● System.out.println( x=x.concat(" Java") );
● Output -> "Core Java”
String Concatenation (contd..)
58. Slide 58
● Use the following to make ample modifications to character
strings:
● java.lang.StringBuffer
● java.lang.StringBuilder
● Many string object manipulations end up with a many abandoned
string objects in the String pool
● String Objects are immutable.
StringBuffer sb = new StringBuffer("abc");
sb.append("def");
System.out.println("sb = " + sb); // output is "sb = abcdef"
StringBuffer Class
59. Slide 59
● Added in Java 5.
● Exactly the same API as the StringBuffer class, except:
● It is not thread safe.
● It runs faster than StringBuffer.
StringBuilder sb = new StringBuilder("abc");
sb.append("def").reverse().insert(3, "---");
System.out.println( sb ); // output is "fed---cba"
StringBuilder Class
61. Slide 61
● Correspond to primitive data types in Java.
● Represent primitive values as objects.
● Wrapper objects are immutable.
Wrapper Classes
62. Slide 62
● Casting operator converts one variable value to another where two
variables correspond to two different data types.
variable1 = (variable1) variable2
● Here, variable2 is typecast to variable1.
● Data type can either be a reference type or a primitive one.
Casting for Conversion of Data type
63. Slide 63
● When one type of data is assigned to another type of variable,
automatic type conversion takes place if:
● Both types are compatible.
● Destination type is larger than the source type.
● No explicit casting is needed (widening conversion).
int a=5; float b; b=a;
● If there is a possibility of data loss, explicit cast is needed:
int i = (int) (5.6/2/7);
Casting Between Primitive Types
64. Slide 64
● One class types involved must be the same class or a subclass of
the other class type.
● Assignment to different class types is allowed only if a value of the
class type is assigned to a variable of its superclass type.
● Assignment to a variable of the subclass type needs explicit
casting:
String StrObj = Obj;
● Explicit casting is not needed for the following:
String StrObj = new String(“Hello”);
Object Obj = StrObj;
Casting Between Reference Types
65. Slide 65
● Two types of reference variable castings:
● Downcasting:
Object Obj = new Object ( );
String StrObj = (String) Obj;
● Upcasting:
String StrObj = new String(“Hello”);
Object Obj = StrObj;
Casting Between Reference Types (contd..)