James Gosling: idealism, the Internet and Java, Pt I

Sunday 9 May 2021

Demonstration of Java NullPointerException

NullPointerException causes and reasons

Since Java is object oriented programming language, every thing is considered to be an object. and there is always a scope of an object to be null or "No value". 

Since Java supports primitive data types, Java is not considered to be pure Java object oriented programming language. 


Few Notable points about NullPointerException

  1. NullPointerExceptions is unchecked exception
  2. Please read post Exception handling and java keywords before reading this article
  3. Usually if program tries to fetch the value from reference and finds nothing as value, then program throws NullPointerException
  4. 'Zero' is not null
  5. And empty String is not considered to be null
  6. It is not the subclass of RuntimeException class

Demo code that throws NullPointerException 



package com.allabtjava.blog;

public class DemoNullPointerException {

class BeanDemo {
String name;
Integer ID;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getID() {
return ID;
}
public void setID(Integer iD) {
ID = iD;
}
}
public DemoNullPointerException() {
}
public void createNullPointerException() {
BeanDemo bean = new BeanDemo();
bean.setName("All about Java!");
System.out.println(bean.getName());
if(bean.getID() == null) {
throw new NullPointerException();
}else {
System.out.println(bean.getID());
}
}
public static void main(String args[]) {
new DemoNullPointerException().createNullPointerException();
}
}

Output


All about Java!
Exception in thread "main" java.lang.NullPointerException
at com.allabtjava.blog.DemoNullPointerException.createNullPointerException(DemoNullPointerException.java:36)
at com.allabtjava.blog.DemoNullPointerException.main(DemoNullPointerException.java:44)

Monday 26 April 2021

Evolution of Java Programming Language

Evolution of Java:

First of all, The Java programming language and it's tools that we currenly using is not what actually expected. This language started as a project to give solutions for embedded devices, mobile phones and other portable peripherals. 

Initially, the Java was called Oak. 


Why it is Oak first..? and Why it transformed to Java..?


The team of five technocrats including Dr. James Gosling and also known as Dr. Java, together working on a project, which expected to give solutions on embedded devices, portable smart devices and TV Set top Boxes etc. at Sun Micro Systems. 

In the process of achieving this solution, at their breaktime, team used to relax with a coffee by having a glimpse on a scenery of Oak tree next to their facility. 

Once the project has come to conclusion and in the process of giving a title to it, they noticed the Oak trees [Always observing them in their break time], they named this programming language as Oak.

Oak Logo


Why it transformed to Java..?

When the first version of Oak is about to release, The trademark search revealed that Oak is already registered for Oak Technologies company. Then, Java was named to this project.

In the previous paragraph, it is told that, "team used to relax with a coffee by having a glimpse on a scenery of Oak trees next to their facility...". When one of the team members asked to barista, [Usually a coffee bar tender is called with that name] about the name of the coffee bean that she/he serves in the break..? The reply was "Coffee is made of Java Beans.."




Immediately the name of the project confirmed to be Java and first version 1.0 is released into the industry in the year 1994. Rest we know, how Java programming language was developed and evolved into the bigger scope like smart phones, Inbuild JRE into web browsers etc.

The Oracle claims that more than 1 billion devices uses JRE and millions of developers uses Java and it's tools every day.

Java Version 16  is released in March 2021.




Few of the Java products are:

  • TV Set top Boxes,
  • Android OS
  • Realtime JVMs
  • Embedded devices
  • Almost all Browsers


Java evolved almost 30 years ago since 1994 from it's first version and almost all devices used Java and it's products directly or indirectly in their daily use. Hope Java continues it's charisma infinity days and will do wonders.


Happy Coding..! :)  



Thursday 22 April 2021

Java programming language and IDEs

IDE: Integrated Development Environment

Integrated development environment, in short IDE is a convenient environment to write, execute and  debug the code or programs on a single platform. IDEs support not only writing code smoothly but also provides a provision to write scripts, XML files, simple text files and build scripts like Ant, Maven are few among others.

In short IDEs are development environments to execute complete development activities using one application.


IDEs and Editors

IDEs and Editors fulfills the same purpose. That is writing code. But IDEs are glued or closely works with respective programming language's compilers, runtime environments, profilers and other language specific tools to put developer in a comfortable zone. 

Some of the features of IDE:
  1. Auto completion
  2. Syntax Highlighting
  3. Code debugger
  4. Profilers
  5. Multipage editors

Auto completion:

Auto completion feature suggests APIs [methods, classes and interfaces] and keywords etc as we start typing in the editor. This helps in not spending much time on typing APIs.




Syntax Highlighting:

Syntax is a structure of arranging APIs, operators and keywords to make computer instructions, subsequently which becomes executables.

Class names, method names, operators and Keywords are highlighted with different colors and formats to differentiate them and to increase the readability. Syntax highlighting helps importantly when single program or file has thousands of statements or lines.

Code Debugger:

Debugger is a feature to identify bugs, errors and shows intermittent results of set of programming instructions or statements and subsequently helps in correcting and developing a bug free computer programs






Profilers:

Profiler is the tool usually shipped along with JDK [if it is a Java] and helps in understanding the memory usage of a computer application graphically. These graphics includes different charts and GUI controls. 



Profilers gives information about

  •  Memory usage,
  •  details of Threads being used,
  •  Heap dumps,
  •  CPU utilization etc

Multipage Editors:

Multipage editors shows the same file content in multiple perceptions. For example XML file content can be viewed in different views. 1. Hierarchical view 2. Simple text format and 3. Graphical view etc


  


Few more notable points about IDEs and Editors:

  1. IDEs are scalable to support multiple programming languages
  2. Editors can not be glued to a programming language's compiler
  3. Editors does not support Auto completion
  4. Editors does not support code debugging
 

IDEs for Java and IDEs built using Java

Usually IDEs are developed using different programming languages where, few of them are open source and few are commercial. Few of the industry endorsed IDEs are:

  • Eclipse
  • Netbeans
The above listed IDEs are developed using Java programming language and also used to develop Java applications and programs. It is little tricky to understand for beginners. 
And both IDEs share common features like scalability, modularity, code completion etc.
You can download Eclipse and Netbeans distributions from their respective sites.


Happy Coding! :)

Popular posts

Demonstration of Java NullPointerException

NullPointerException causes and reasons Since Java is object oriented programming language, every thing is considered to be an object. and t...