Java Programming Tips


How to Add Two Matrices in Java

Matrix operations are important in a number of algorithms. It is used in graph theory, geometry, probability theory and image processing. Matrix addition is simple, each entry in first matrix is added to the corresponding entry in the second matrix to get the entry in the result matrix. The following sample program illustrates matrix addition […]

How to Run External Program in Java

From your Java program, it is possible to run other applications in your operating system. This enables you to make use of system programs and command line utilities from your Java program. Here are some typical uses of this feature when running your Java program in Windows, You want to invoke a Windows program such […]

How to Check Whether a Year is Leap Year in Java

Usually there are 365 days in a year. However once every four years, there are 366 days in year. This year is called leap year and on a leap year, February has 29 days. However not all years divisible by 4 are leap years. Following are the rules to determine whether a year is leap […]

How To Reverse a String in Java

There are a multiple ways to solve a programming problem. There may be library classes that may be very useful in solving programming problems. If you don’t know these classes and methods, you will end up  spending time writing your own methods and wasting time. We would use the programming problem of reversing a given […]

How to Take Input From User in Java

Whether you are writing console programs or solving problems in Java, one of the common needs is to take input from the user. For console programs, you need to have access to the command line. Java has a utility class named Scanner which is capable of getting typed input from user. This class can directly […]