Java Series Part 7: Creating Multiplication Table using Classes, Object and Methods

Create a class called Multiplication table as below: Ch7MultiplicationTable.java package com.java.basic; public class Ch7MultiplicationTable { void print() { for(int i=1; i<=10;i++) { System.out.printf("%d * %d = %d", 5, i, 5*i).println(); } } // making it generic to accept parameters that is print table of any number void print(int n) { for(int i=1; i<=10;i++) { System.out.printf("%d … Continue reading Java Series Part 7: Creating Multiplication Table using Classes, Object and Methods

Advertisement

Java Series Part 6 – Classes, Objects and Methods

A method is a block of code which only runs when it is called. You can pass data, known as parameters, into a method. Methods are used to perform certain actions, and they are also known as functions. Java is an object-oriented programming language. Everything in Java is associated with classes and objects, along with its attributes and … Continue reading Java Series Part 6 – Classes, Objects and Methods

Java Series Part 5 – JVM, JRE and ByteCode

JVM, JRE and JDK JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn't physically exist. It is a specification that provides a runtime environment in which Java bytecode can be executed. It can also run those programs which are written in other languages and compiled to Java … Continue reading Java Series Part 5 – JVM, JRE and ByteCode

Java Series Part 4 – Strings & String Concatenation

Strings are used for storing text. A String variable contains a collection of characters surrounded by double quotes: String greeting = "Hello"; A String in Java is actually an object, which contain methods that can perform certain operations on strings. For example, the length of a string can be found with the length() method: String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; System.out.println("The … Continue reading Java Series Part 4 – Strings & String Concatenation

Java Series Part 3 – Variable/Data Types

Primitive Data Types Data types that can store integer values: int i;byte b;short s;long l; Variable types: byte b = 5; //8bits - 128 to 127short s = 128 //16bits - 32,768 to 32,767int i = 40000; //32 bits - 2,147,483,648 to 2,147,483,647long l = 222222222; //64bits -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807float f = 4.0f; //32 bits … Continue reading Java Series Part 3 – Variable/Data Types

Java Series Part 2: Java Variables

Variables in Java are containers for storing data values. In Java, there are different types of variables, for example: String - stores text, such as "Hello World". String values are surrounded by double quotes int - stores integers (whole numbers), without decimals, such as 15 or -15 float - stores floating point numbers, with decimals, such as 1.99 or -1.99 … Continue reading Java Series Part 2: Java Variables

Java Series Part 1: Java Expressions

A Java expression consists of variables, operators, literals, and method calls. package com.java.basic; public class ExpressionsExample { public static void main(String args[]) { // 5 + 2 is an expression int add = 5 + 2; System.out.println("Addition= " + add); // 5 - 2 is an expression int sub = 5 - 2; System.out.println("Substraction= " + … Continue reading Java Series Part 1: Java Expressions

Error: kie.container or kieModule bean – Null Pointer Exception? Solved!

I recently we faced an issue in my Drools Config class where we added config for kie container and kie modules. It was working fine in normal windows server environment but we migrated our app into docker environment we faced below error. When running our Java Spring Boot app (Fat Jar) on Docker Environment we … Continue reading Error: kie.container or kieModule bean – Null Pointer Exception? Solved!

Mockito 101 – Unit Testing in Java Apps

Mockito is an open source framework that allows you to easily create mocks (test doubles). Mocks are objects that have return values to method executions made during the test and has recorded expectations of these executions. Mocks can also throw an exception if they receive a call they don’t expect. They are checked during verification to ensure … Continue reading Mockito 101 – Unit Testing in Java Apps