Solve Cannot make a static reference to the non-static method Error

Here you will learn to solve error “cannot make a static reference to the non-static method” or “non static method cannot be referenced from a static context”. Lets take one example where this error occurs. When you will compile below code then you will get an error.

Why this Error Occurs? This error occurs when we try to access a non static method or member directly inside a static method. In above code print() is a non static method

Read more

Java Read and Write Excel File Using Apache POI

Apache POI provides libraries for reading and writing excel file in Java. There are other libraries available in market but Apache POI is most popular and reliable among them. In this tutorial I will show you how you can read or write data to excel file in Java using Apache POI Library. There are few things that you should know about this library. Class prefixed by HSSF are used to perform operations on MS Excel 2003 file. For example, HSSFWorkbook and

Read more

JDBC Transaction Management in Java with Example

Here you will learn to implement JDBC transaction management in java. By default database is in auto commit mode. That means for any insert, update or delete operation the changes takes place immediately in database. What is Transaction? Transaction involves several sql queries that are considered as one unit. For example money transfer done in bank is a kind of transaction as it involves two steps. First debit the x amount of money from source account and then credit that

Read more

Advantages and Disadvantages of Java Language

Here I will discuss about some important advantages and disadvantages of Java language. Advantages of Java There are several advantages or merits of java that are explained below. Platform Independent It is one of the biggest merit of java language. When a java program is compiled it is converted into .class file or byte code. The .class file is platform independent and can run on any platform like windows, mac, linux, etc. This property is known as Write Once Run

Read more

Pascal Triangle in Java

Here you will learn about pascal triangle in java with a program example. What is Pascal’s Triangle? It is a triangular array of the binomial coefficients. It is a number pattern which starts with 1 at top and then placing numbers below it in triangular pattern. Each number is obtained by adding two numbers above it. Take below example, here 4 is obtained by adding 1 and 3 above it. Below I have shared the java program to print pascal

Read more

Difference Between Java, Core Java and Advance Java

Here you will learn about difference between java, core java and advance java. Mostly beginner java programmers have confusion about these 3 terms in their mind. Below I have explained them to clear their confusion. Java It is a high level programming language. Java is available in three flavors. Java Standard Edition (J2SE or JSE) Java Enterprise Edition (J2EE or JEE) Java Macro Edition (J2ME or JME) Java is a combination of above there things. Core Java (J2SE or JSE)

Read more

How to Create Executable JAR File in Eclipse IDE?

Here you will learn how to create executable jar file in eclipse. An eclipse ide provides facility to convert a project into executable jar file in java. This process is really helpful in case you have development some desktop application in java and want an executable file to directly run the application. Also Read: How to Add or Import Jar in Eclipse Project For demonstration purpose I have given simple java program to develop a gui application using swing. You can use

Read more

How Many Ways to Create Object in Java?

How many ways to create object in Java? The answer is there are many ways but in this tutorial I am sharing the 5 ways to do this. Using new Keyword Using object cloning Using Class.forName() Using Class Loader Using Object Deserialization Below I have discussed each of these methods one by one with example.   How Many Ways to Create Object in Java? Method 1: Using new Keyword It is most common and popular method to create object in

Read more
1 2 3 10