Javascript – Common methods for Build-in classes

Javascript – Common methods for Build-in classes

Date Array You can also define an array var a = new Array(); or with initial values: var a = new Array(11, 22, 33, 44); if you put only one argument then you specify the length of the array: push(element) – add a new array element at the end pop() – deletes the last element join(char) – joins all the elements of an array with the character you specify and return it as a string splice(start, end) – removes elements splice(start, howMany to removed, newElement, newElement…) – you can replace…

Javascript – Common methods for Build-in classes Read More

Javascript – Classes

Javascript – Classes

Javascript introduced classes in ES6 (ECMAScript2015). To define a class you need to use the class keyword and add a constructor method which is executed when a new object is created. You must declare a class before you use it. You can create new objects from this class using the new keyword In classes, the functions are defined only with their name, without the function keyword Static methods Static methods are created using the static keyword. They can be used without an object creation. You do not need to create…

Javascript – Classes Read More

Java – Abstract classes & methods

Java – Abstract classes & methods

Abstract class is a class where its implementation is incomplete or non-existent. Abstract class cannot be instantiated but can be extended. A subclass that implements an abstract class can be instantiated. Abstract class is similar to interface but also have some differences. Both cannot be instantiated and both can contain methods without implementation. The differences are: a class can extend only one class but can implement many interfaces separating them with “,” An abstract class can define fields that are not static nor final. An interface all fields must be…

Java – Abstract classes & methods Read More

Java – Classes and methods

Java – Classes and methods

Method is a group of statements to which we give a name so we can execute them. When we call a method, the program first executes the statements in the method and then it continues with the code below the method call. syntax: modifier returnType methodName(Parameters){ statement(s) } modifier: (access modifiers) public | private | protected and (non-access modifiers) static | final | abstract returnType: If the method returns a value then you should specify the type here. Use return as the last statement in the method. If not then…

Java – Classes and methods Read More

Java – Classes

Java – Classes

Class is a blueprint of an object, it describes the object. An object is an instance of a class. Java is Object-Oriented Programming (OOP) language, that means that supports objects and programs written in Java perform most of their actions/behaviour with objects. syntax: public class ClassName{ variables/state methods/behavior} Create a new class with IntelliJ IDEA Right-click src directory, New and then Java Class. You will see the following pop-up window. Specify the Name and click Ok. The Class file name should be the same as the class name and it…

Java – Classes Read More