An intermediate level session where we delve deeper into the concepts of Java and learn how to code these out.
Between each lesson, you'll have skill testing in the form of quizzes, as well as hands-on experience in the field.
1. Learn To Code: Diving Deep into Java
Jahnavi Bollineni
Core Team Member
T R Sai Rakshith
Technical Team Member
2. Java Methods
● Java Methods can be defined as a collection of statements that perform a specific task
and return the result to the caller.
● A method can also perform a specific task without returning anything.
● Retyping the code makes it difficult to interpret and decreases the code quality.
Methods help us in reusing the code.
● A method needs to be called to use its functionality.
● When you call the System.out.println() method, the system executes several
statements in order to display a message on the console.
3. Features of Java Methods
●Reducing Duplication of Code.
●Making complex problem to simpler ones.
●Improving quality of code.
●Reusing of Code
●Information hiding
6. Calling a Method
In Java, a method needs to be called for using
its various functionalities. There can be three
situations when a method is called:-
● It completes all the statements in the method.
● It reaches a return statement.
● Throws an exception.
7. Java Strings
● Strings are used to store text.
● A string variable contains a collection of characters surrounded by double quotes.
● A string in Java is actually an object, which contains methods which can perform
certain operations on strings.
● For Example, the length of a string can be found out using the length() method.
● The indexOf() method returns returns the index of the first occurrence of the
specified text in the string.
● Note: This includes whitespaces as well.
8. ● The + operator can be used between strings to combine them. This process is
referred to as string concatenation.
● We could also use the “concat” method in order to concatenate the strings.
● In order to check if the given string contains a particular word or alphabet we use the
method “contains”
● Use the “endsWith” method and specify the suffix in the arguments.
● Java String Replace, replaceAll and replaceFirst methods. You can specify the part of
the String you want to replace and the replacement String in the arguments.
Java Strings
9. Arrays
● Collection of similar type of elements.
● Arrays are dynamically allocated.
● Fixed set of elements in a Java array.
13. Constructors
● A special method that is used to initialize objects.
● A constructor has the same name as that of the class.
● Does not have any return type.
class Main {
Main() {
// constructor’s body
}
}
14. Types of Constructors
In Java, constructors can be divided into 2 types:
● No-Argument Constructor
● Parameterized Constructor
15. Files and I/O
● File handling is an important part of any application.
● Java has several methods for creating, reading, updating, and
deleting files.
● The File class from the java.io package, allows us to work with
files.
● To use the File class, create an object of the class, and specify
the filename or directory name