Introduction to Java Functional Programming
Function<String, String> modifyString = (name) -> name.toUppecCase().concat(“modified”);
Read More Introduction to Java Functional ProgrammingFunction<String, String> modifyString = (name) -> name.toUppecCase().concat(“modified”);
Read More Introduction to Java Functional ProgrammingIn this lesson, you will learn about Java history, the types of Java programs, and what Java editions exist today. History Sun Microsystems Inc developed Java in 1991 by the Green Team, whose members were James Gosling, Mike Sheridan, and Patrick Naughton. First, it was developed as a pilot project of a simple language for programming smart home…
Read More Introduction to JavaIn today’s world of agile development, writing unit tests is vital and helpful in producing high-quality code. Unit tests ensure that the code complies with quality standards and that issues are identified before deployment. Java offers various testing frameworks to make the lives of developers easier, with Mockito being one of the well-known ones. In…
Read More An Introduction to the Mockito Frameworkclass Test { public void print(String word) { System.out.println(word); } } class Test2 { public void callPrintMethod() { Test test = new Test(); test.print(“Hello”); } } class Test { public static void print(String word) { System.out.println(word); } public static void main(String[] args) { print(“Hello!”); // OK Test.print(“Hello!”); // OK } } class Test2 { public…
Read More Java Instance and Static Methodspublic void methodName() { // code to be executed } public void methodName(int num, String data) { // code to be executed } methodName() methodName(10, “dataString”); class Test { public int sumNumbers(int a, int b) { int sum = a + b; return sum; } public static void main(String[] args) { int num1 = 10;…
Read More Methods in Javatype variableName = variableValue; public class Car { String brand; int maxSpeed; } class Car { String brand; int maxSpeed; public void printFields() { System.out.println(“BRAND: ” + brand); System.out.println(“MAX SPEED: ” + maxSpeed); } } public class Test { public static void main(String[] args) { Car ford = new Car(); ford.brand = “Ford”; ford.maxSpeed =…
Read More Variable in Javaclass Car { int numberOfSeats = 4; void addOneSeat(int numberOfSeats) { numberOfSeats = numberOfSeats + 1; // changes will only affect the local variable } public static void main(String args[]) { Car car = new Car(); System.out.println(“Number of seats before the change: ” + car.numberOfSeats); car.addOneSeat(car.numberOfSeats); System.out.println(“Number of seats after the change ” + car.numberOfSeats);…
Read More Java Pass-by-Value vs Pass-by-ReferencePrimitive type Wrapper class boolean Boolean byte Byte char Character float Float int Integer long Long short Short double Double class Test { int id = 5; Integer id1 = id; // autoboxing } class Test { public static void main(String[] args) { int a = 10; int b = 20; List<Integer> list = new…
Read More Autoboxing and Unboxing in Javabyte Uses 1 byte (8 bits) for a binary record of integers Values of this type are integers in the range -2 ^ 7 to 2 ^ 7-1, ie. [-128, 127] The default value is 0 Example: byte var1=120, byte var2=-30 short Uses 2 bytes (16 bits) to write integer binaries Values of this type…
Read More Java Data types1 public class HelloWorldClass { 2 3 public static void main(String[] args) { 4 System.out.println(“Hello World!”); 5 } 6 }
Read More How to Compile and Run your First Java Programclass Test { public static void main(String[] args) { short a = 10; int b = a; // automatically converts the short type into int type int c = 10; long d = c; // automatically converts the integer type into long type float f = d; // automatically converts the long type into float…
Read More Type Casting in JavaOperator Description Example + Indicates positive value +a – Negates an expression value (Converts positive number to negative) -a ++ Increments a value by 1 ++a — Decrements a value by 1 –a ! Inverts the value of a boolean type !true gives false %= Assigns the remainder to the left operand when dividing the…
Read More Java operators