Software design or System design is one of the tricky concepts to master. You
can quickly learn a programming language like
Java or
Python, but creating software using that programming language is a totally
different thing. That's where software design and coding skills come to the
rescue. It's actually an art to structure your program, design your modules,
specify boundaries and interactions with other parts of the system so that
they are easier to read, maintain, and flexible to change. It's one of the
most essential skills for a
software developer
but often gets ignored. If you look for an online course to learn Software
design and architecture, you won't find many, forget about good ones.
Learn Java and Programming through articles, code examples, and tutorials for developers of all levels.
What is blank final variable in Java - Example
What is a blank final variable in Java?
The blank final variable in Java is a final variable that is not initialized while declaration, instead they are initialized in a constructor. Java compiler will complain if a blank final variable is not initialized during construction. If you have more than one constructor or overloaded constructor in your class then a blank final variable must be initialized in all of them, failing to do so is a compile-time error in Java. Alternatively, you can use constructor chaining to call one constructor from another using this keyword, in order to delegate initialization of a blank final variable in Java. In this Java tutorial, we will see what is blank final variable is in Java and a code example on How to use a blank final variable.
Access Modifiers in Java - Public, Private, Protected, and Package Examples
public, private, protected and package or default are four access modifiers available in Java. These access modifiers provide Java programmers to control the accessibility or visibility of a class, method, or any field of a class. A good understanding of public, private, or protected modifiers is required in order to implement proper encapsulation in Java and create a Java program that is easier to maintain. In this Java tutorial, we will see what is public, private, protected and default modifiers are, which modifiers can be used with top-level class and nested class, and what is the difference between public, private, protected, and default modifiers in Java.
How to display date in multiple timezone in Java with Example - PST GMT
We can use SimpleDateFormat class to display a date in multiple Timezone in Java. While working in a global Java application it's quite common to display dates in the different time zone, classical example is Server is running on either PST or GMT timezone and clients are global or at least running on global trading hubs like Hong-kong, Mumbai, Tokyo, London, etc. Unfortunately, the Date and Time API in Java is quite tricky and until you have a good understanding of Date and Time classes and methods like Calendar, SimpleDateFormat, and thread-safety issues, You can easily create bugs.
JDBC - How to Convert java.sql.Date to java.util.Date in Java with Example
How to convert java.sql.Date into a java.util.Date and vice-versa is a popular JDBC interview question which is also asked a follow-up question of the difference between java.sql.Date and java.util.The date which we have seen in our last article. Since both SQL date and Util date store values as a long millisecond, converting them back and forth is easy. Both java.sql.Date and java.util.The date provides a convenient method called getTime() which returns a long millisecond equivalent of a wrapped date value. Here is a quick example of converting java.util.Date to java.sql.Date and then back to util Date.
5 Essential JDK 7 Features for Java Programmers
What is new in Java or JDK 7
It's close to a year now JDK 7 or Java 7 has been released, still, programmer asks what is new in Java 7 ? What is the best feature introduced in JDK7, where is the list of all Java 7 new features, etc? I thought to let's document Top 5 new features introduced in Java 7 for easy reference, this will not only answer What is new in Java 7 but also provide a quick overview of What are those features in Java 7. Java 7 introduced many new features in Java programming language like try-catch with a resource, String in Switch, etc but it also makes a lot of changes on Java Development API by introducing a new File API in Java and several other minor changes. Like you can now find hidden files from the Java programs without applying any hack. anyway let's see my list of Top 5 Java 7 features :
It's close to a year now JDK 7 or Java 7 has been released, still, programmer asks what is new in Java 7 ? What is the best feature introduced in JDK7, where is the list of all Java 7 new features, etc? I thought to let's document Top 5 new features introduced in Java 7 for easy reference, this will not only answer What is new in Java 7 but also provide a quick overview of What are those features in Java 7. Java 7 introduced many new features in Java programming language like try-catch with a resource, String in Switch, etc but it also makes a lot of changes on Java Development API by introducing a new File API in Java and several other minor changes. Like you can now find hidden files from the Java programs without applying any hack. anyway let's see my list of Top 5 Java 7 features :
Difference between DOM vs SAX Parser in Java - XML Parsing in Java
DOM vs SAX parser in Java
DOM and SAX parser are the two most popular parsers used in the Java programming language to parse XML documents. DOM and SAX concept is originally XML concept and Java programming language just provide an API to implement these parsers. Despite both DOM and SAX are used in XML parsing, they are completely different from each other. In fact difference between DOM and SAX parser is a popular Java interview question asked during Java and XML interviews. DOM and SAX parser has a different way of working, which makes Java programmer understand the difference between DOM and SAX parser even more important.
DOM and SAX parser are the two most popular parsers used in the Java programming language to parse XML documents. DOM and SAX concept is originally XML concept and Java programming language just provide an API to implement these parsers. Despite both DOM and SAX are used in XML parsing, they are completely different from each other. In fact difference between DOM and SAX parser is a popular Java interview question asked during Java and XML interviews. DOM and SAX parser has a different way of working, which makes Java programmer understand the difference between DOM and SAX parser even more important.
Difference between static and non static nested class in Java? Example
Static vs. non Static class in Java
In Java, you can make a class either static or non-static. Now, what is the difference between making a class static vs. non-static? Well, there is a lot of difference between them. First of all, there are two kinds of classes in Java, one is called a top-level class, and the other is called a nested class. As the name suggested, a top-level class is a class that is declared in the .java file and not enclosed under any other class. On the other hand, a nested class is declared inside another class. The class which enclosed nested class is known as Outer class.
How to read file in Java using Scanner Example - text files
Reading a file with Scanner
From Java 5 onwards java.util.Scanner class can be used to read
file in Java. Earlier we have seen examples of reading
file in Java using FileInputStream and reading
file line by line using BufferedInputStream and in this Java tutorial, we
will See How can we use Scanner to read files in Java. Scanner is a
utility class in java.util package and provides several
convenient methods to read int, long, String, double etc from a source which can be an InputStream,
a file, or a String itself.
Difference between throw vs throws in Java? Answer
throw vs throws in Java
throw and throws are two Java keywords related to the Exception feature of the Java programming language. If you are writing a Java program and familiar with What is Exception in Java, it's a good chance that you are aware of What is throw and throws in Java. In this Java tutorial, we will compare throw vs throws and see some worth noting differences between throw and throws in Java. Exception handling is an important part of the Java programming language which enables you to write robust programs. There are five keywords related to Exception handling in Java like try, catch, finally, throw, and throws.
How to read User Input from Console in Java? Scanner Example
Apart from reading files, Scanner can also read user input from Console in Java. Just like in the case of reading files, we have provided File as a source for scanning, We need to provide System.in as a source to scan for user input in Console. Once you created and initialized java.util.Scanner, you can use its various read method to read input from users. If you want to read String, you can use nextLine(), if you want to read integer numbers, you can use nextInt().
How to Find IP address of localhost or a Server in Java? Example
In today's Java programming tutorial, we will learn some networking basics by exploring the java.net package. One of the simple Java network programming exercises, yet very useful, is to write a program to find the IP address of the local host in Java. Sometimes this question is also asked to find the IP address of the Server on which your Java program is running or find the IP address of your machine using Java etc. In short, they all refer to localhost. For those who are entirely new in the networking space, there are two things to identify a machine in a network, which could be LAN, WAN, or The Internet.
15 People Java Developers Should Follow on Twitter
If you are passionate about Java and would like to follow Java bloggers into Twitter then here is my list of 15 people you can follow on Twitter to keep yourself up-to-date and engage in the Java world. These people regularly share the latest things in Java, JVM, Spring, Hibernate, and other Java technology. By following them, you will not only know about their latest work but also what's happening in the Java world. You might be thinking just 15 people, well, there are many more who is not on this list but I regularly share their Twitter handles via my Twitter account @javinpaul and @Javarevisited. If you are following me then you will automatically get to know about them.
Java Keyword Cheat Sheet - Meaning and Usage
Knowing keywords of a programming language is very important to understand its features, and Java has rich set of keyword, going along with rich set of functionalities. The first keyword, I learn while writing Java program was public, static and void, not surprisingly they are picked from main method. Our instructor explained meaning of each keyword, saying that its, always remember why main is public, static and void main Java.
Video example - Dijkstra's Algorithm shortest path in Graph
Video example - Dijkstra's Algorithm shortest path in Graph
Dijkstra's
Algorithm in Graph
theory allows you to find least cost
path or shortest path between two nodes in directed and weighted graph. Dijkstra's
Algorithm is one of the important concept of Graph theory and often asked in
Exams and interviews. Frankly speaking Its not easy to understand Dijkstra's
Algorithm , at least until you have a good example and this leads me to search
for simple and easy to learn example of Dijkstra's Algorithm which landed me on
this video. I have earlier shared Graph traversal BFS and DFS algorithm from
this same author and when I found his video on Dijkstra's Algorithm, I knew
this is going to be another best. By the way Dijkstra's Algorithm has several
practical usage like finding shortest path between cities for Air planes route
or bus route as cities and driving path between cities fits nicely
as vertices
of Graph and directed and weighted path between them. In Dijkstra's Algorithm ,
path between two nodes which are unreachable directly is assumed as infinity. I
suggest watching this video example more than one time if you are unsure how
Dijkstra's Algorithm works.
How to remove duplicate(s) from linked list in Java? Example Tutorial
Hello guys, if you are wondering how to find duplicates in a given linked list
in Java then you have come to the right place. In the past, I have explained
how to reverse a linked list in Java, find kth element from tail in linked list, find cycle on linked list, and in this article, I will show you how to find duplicate nodes in a given
linked list. This is one of the classic linked list coding problem and I have
also included this in my list of
30 common linked list problems
for programmers. You can further check that list to practice more linked list
programs and improve your understanding of linked lists and how to solve those
problems. But, before we get into details of finding and printing duplicate
nodes from the given linked list let's start with the basics.
How to print a Right Triangle Pattern in Java - Example Tutorial
Hello Java Programmers, here we are back again with a pattern based exercise. In the past, I have shared article on how to print pyramid pattern of stars in Java, Left Triangle Star Pattern, and Pyramid pattern of alphabets, and in this article, I will show you how to print a right triangle start pattern in Java. Pattern based exercises are great way to learn programming and coding as it encourage you to use logic and use essential programming constructs like loop and arrays.
How to Check if Given Number is Prime in Java - With Example
Hello guys, today, we are going to discuss one of the most common programming exercises for beginners is, write a program to check if a given number is prime or not? There are many ways to check if a number is prime or not, but the most common of them is the trial division, which is what we will see in this tutorial. In my opinion, these kinds of programs are their first steps towards algorithmic understanding. You first come up with a solution, which is driven by the fact that prime numbers are natural numbers, that are not divisible by any positive number other than 1 and themselves. Then, you write a for loop to check every number, starting from 1 to a given number, to see if the given number is divisible by any positive number or not. This leads you to the solution.
How to Find Greatest Common Divisor of two numbers in Java - [ Euclid's algorithm GCD Example]
How to find the Greatest Common Divisor of two numbers in Java
Simple Java program to find GCD (Greatest Common Divisor) or GCF (Greatest Common Factor) or HCF (Highest common factor). The GCD of two numbers is the largest positive integer that divides both the numbers fully i.e. without any remainder. There are multiple methods to find GCD, GDF, or HCF of two numbers but Euclid's algorithm is very popular and easy to understand, of course, only if you understand how recursion works. Euclid's algorithm is an efficient way to find the GCD of two numbers and it's pretty easy to implement using recursion in the Java program. According to Euclid's method GCD of two numbers, a, b is equal to GCD(b, a mod b) and GCD(a, 0) = a.
Fibonacci Series in Java Using Recursion
Fibonacci series in Java
Write a Java program to print the Fibonacci series up to a given number or create a simple Java program to calculate Fibonacci number is common Java questions on fresher interviews and homework. Fibonacci series is also a popular topic on various programming exercises in schools and colleges. Fibonacci series is a series of natural numbers where the next number is equivalent to the sum of the previous two numbers like fn = fn-1 + fn-2. The first two numbers of the Fibonacci series are always 1, 1. In this Java program example for the Fibonacci series, we create a function to calculate Fibonacci numbers and then print those numbers on the Java console.
Write a Java program to print the Fibonacci series up to a given number or create a simple Java program to calculate Fibonacci number is common Java questions on fresher interviews and homework. Fibonacci series is also a popular topic on various programming exercises in schools and colleges. Fibonacci series is a series of natural numbers where the next number is equivalent to the sum of the previous two numbers like fn = fn-1 + fn-2. The first two numbers of the Fibonacci series are always 1, 1. In this Java program example for the Fibonacci series, we create a function to calculate Fibonacci numbers and then print those numbers on the Java console.
Subscribe to:
Posts (Atom)