Professional Documents
Culture Documents
PPL Lecture6
PPL Lecture6
(Lecture 6)
Fundamentals of JAVA
Java is a high-level, general-purpose, object-oriented, and secure programming
language developed by James Gosling at Sun Microsystems, Inc. in 1991. It is
formally known as OAK. In 1995, Sun Microsystem changed the name to Java.
In 2009, Sun Microsystem takeover by Oracle Corporation.
Editions of Java
Each edition of Java has different capabilities. There are three editions of Java:
import java.io. *;
class GFG {
public static void main(String[] args)
{
// invalid declaration -- If we want to assign
// size of array at the declaration time, it
// gives compile time error.
int a[5];
// valid declaration
int b[];
}
}
Two-Dimensional Array
Suppose, you want to create two-dimensional array of int type data. So you
can declare two dimensional array in many of the following ways:
Example:
import java.io. *;
class GFG {
public static void main (String[] args)
{
Example:
• class Main{
• public static void main(String []args)
• {
• String s1="Adithya";
• String s2="Adithya";
• String s3="Adi";
• boolean x=s1.equals(s2);
• System.out.println("Compare s1 and s2:"+x);
• System.out.println("Character at given position is:"+s1.charAt(5));
• System.out.println(s1.concat(" the author"));
Code explanation
• Lines 4-6: We create three strings s1, s2, and s3.
• Line 7: We compare two strings s1 and s2 using equals () function.
• Line 9: We find the character at position 5 in string s1 using char
At() function and print it.
• Line 10: We concatenate two strings using the concept () function.
• Line 11: We find the length of string s1 using length () function.
• Line 12: We convert the string s1 to lowercase letters using to
Lowercase() function.
• Line 13: We convert the string s1 to uppercase letters using to
Uppercase() function.
• Line 14: We find the index of a in string s1 using index Of() function.
• Lines 15-16: We find the substring by passing indexes as parameters to
the substring () function.