Java
Java
JVM - Java Virtual Machine platform component that execute programs (interpreter, end user)
JRE - Java RunTime Environment Is on disk part java that creates the JVM
JRE is part of JDK because the java development process requires JRE because
running java programs is part of the development process.
————Arrays—————
Arrays are used to store multiple values in a single variable, instead of declaring
separate variables for each value.
————ForEach in Java————
for(String i : cars) {
System.out.println(i);
}
Method is a block of code which only runs when it is called. You can pass data known
as parameters into a method.
If You want a method to return value you need to set a primitive data type instead of
void.
Overriding means having two methods with same name and parameters. One of the
methods is in parent class and the other is in the child class.
When individual object are created they inherit all the variables and methods from class.
————Contructors in Java————
Access modifier —> Meaning that it is used to set access level for classes, attributes,
methods and contractors.
Encapsulaton is to make sure that sensitive data is hidden from users. TO achieve this
you must:
Encapsulation, better control of class attributes and methods. Class attributes can be
made read only if only use get method or write only if we use set method. Increased
security of data.
————Inaritance————
In Java it is possible to inherit attributes and methods from one class to another.
If you don’t want other classes to inherit from a class, use the final keyword.
———Polimorfizam———
Means many forms, and it accurs when we have many classes nah are related to each
other by inheritance.
Inheritance lets us inherit attributes and methods from another class. Polymorphism
uses those methods to perform different tasks.
Inner classes
That means that is possible to nested classes. The purpose of nested classes is to
group classes that belong together, which makes code more readable.
Data abstraction is the process of hiding certain details and showing only essential
information to the user.
Abstraction can be achieved with either abstract classes or interfaces.
Abstract class is a restricted class that cannot be used to create objects to access it you
must inherited from another class.
Abstract method can only be used in an abstract class and it does not have a body. The
body is provided by subclasses.
————Interface — — — —
To access the interface methods the interface must be implemented by another class
with implements keyword.
Class can only inherit from one superclass, but you can implement more than one
interface.
—————Enums—————
Java collections can achieve all the operation that you perform on data such as
searching, sorting, insertion, manipulation and deletion.
———ArrayList———
while(its.hasNext()) {
System.out.println(itr.next());
}
———LinkedList————
It uses a doubly linked list internally to store the elements. It can store duplicate
elements, it maintains the insertion order. Manipulation is fast because no shifting is
required.
whilde(itr.hasNext()) {
System.out.println(itr.next());
}
——————SET Interface—————
It represents the unordered set of elements which doesn’t allow us to store duplicate
items. We can store at most one null value in Set. Set is implemented by HasSet,
LinkedHashSet and TreeSet.
HashSet represents the collection that uses a hash table for storage. It contains a
unique items.
LinkedHashSet it extends the HashSet class and implements Set interface. It also
contains unique elements, but it maintains the insertion order and permits null elements.
TreeSet also contains unique elements. However the access and retrieval time of
TreeSet is quite fast. The elements of TreeSet stored in ascending order.
———————HashMap———————
HashMap contains values based on key, only unique keys, may have one null key and
multiple null values, maintains no order.
Differences between HashSet and HashMap is that HashSet contains only values.