Understanding Packages and classpath in Java

What is Package?

Package in Java is a way of organizing the code. In simple terms, its an directory or directory hierarchy which is used to store the code files. A statement like import java.util.Scanner means that on system java is a directory which in turns have sub directory name util, which have Scanner class. To create custom package the procedure is to create a directory and sub directories and declare it java file. Consider a class A, which belongs to a package org.demo, save it as A.java. Continue reading “Understanding Packages and classpath in Java”

Comparing user defined objects : Comparable and Comparator

Comparison plays important role in any programming language. Almost all the sorting techniques involves comparison. In Java, all the predefined classes and primitive data types supports comparison. User defined data types needs to provide the comparison logic, Comparable and Comparator comes in picture. For the primitive data type, how to compare is inbuilt and can be achieved using different comparison operators like <, >, <=, >=. Assume int a = 10 and int b = 20, then a<b is true. Continue reading “Comparing user defined objects : Comparable and Comparator”

Understanding Object class

Object class is a super class of all class in Java. All inheritance hierarchies starts from Object class followed by other class. Consider example class Shape as parent class of Rectangle and Circle class, in that case Object class is parent or super class of Shape class hence Rectangle and Circle class not only get methods and properties of Shape class but also Object class. This article shows the methods of Object class which is inherited by all the classes that are predefined or user defined. Continue reading “Understanding Object class”

Introduction to Java – What is Java?

Java is a general purpose programming language. The main feature that makes the Java language popular is “WORA” i.e. Write Once Run Anywhere. It means programs once written can run on any platform. Program written in Windows platform and compiled on Windows platform can run on Linux and Mac platform without recompiling the program or modifying the source code. This is achieved by generating the bytecode during the compiling process. Bytecode is an intermediate format which is than interpreted by JVM [ Java Virtual Machine ] at run time. As name says its a Virtual machine and not a physical machine its job is to translate bytecode in to executable code for the platform on which it is running. Following diagram shows the whole process. Continue reading “Introduction to Java – What is Java?”

Introduction to Jenkins and its features

Continuous Integration (CI) is one of the most popular application development practices and base component for DevOps Culture in modern times. Developers check in for bug fix, new feature development in the code repository. Open Source or commercial CI tool verifies the integration process with an automated build (Build tools such as Ant, Maven, and so on…) and automated test execution framework (such as JUnit) to detect issues with the current source of an application, and provide quick feedback. It also integrates source code analysis using Sonar.

Continue reading “Introduction to Jenkins and its features”

Oracle Certified Associate: Java 8 default and static methods in interface

We all know about the default access modifier in Java. From Java 8, we can add default method(s) to an interface. The default methods are non abstract method which have implementation i.e. to say have a method body. A part from default, Java 8 also supports static method. Continue reading “Oracle Certified Associate: Java 8 default and static methods in interface”

Oracle Certified Associate: Java 8 Formatting Date and Time

In previous post we learned how to manipulate date and time object. In this post we will see how to parse and format the date and time.
For formatting date and time in Java 8 DateTimeFormatter is used which belongs to java.time.format package. It is used to parse the string in to date and time and also used to print the date time in desired format, all date time related class provides two methods for the same viz parse and format. Continue reading “Oracle Certified Associate: Java 8 Formatting Date and Time”

Oracle Certified Associate: Java 8 Date and Time

Java 8 introduces new package for date and time due to many flaws in old version of date and time classes. New package is added named time in java package repository. We required to have basic knowledge about java.time package for Oracle Certified Associate Exam for Java 8. Continue reading “Oracle Certified Associate: Java 8 Date and Time”

Oracle Certified Associate: Java 8 Maniplating Date and Time

In last post on java.time package basics we saw how to create date and time objects. In this post we will see how to manipulate date and time objects.
From previous post we know how to create Date object, lets us try to get month, year and date from the object. Continue reading “Oracle Certified Associate: Java 8 Maniplating Date and Time”