Browsing Tag
Core Java
31 posts
Count line word and characters in file
In this example we’ll see how to count line, word and characters in file. package com.javatechig; import java.io.BufferedReader;…
How to delete and rename a file in java
This post provides sample program explaining how to delete and rename a file in java Rename file in Java…
Copy file from one folder to another in java
This example explains how to Copy file from one folder to another in java. package com.javatechig; import java.io.File;…
Copying the Contents of One text file to Another in Java
In this example, we will see a sample program to copying the contents of one text file to another in Java.
How to Create a Text File in Java
In this article we will see the sample code to create a text file in java.In this example, we'll use the PrintWriter class.
Invoke Method Using Java Reflection
Java provides reflection API to do introspection of an object and modify its behavior on the run time. The class Class in the Java API forms the basis to identify the object class and its internal structure of that particular Class. The below three functions are important to get the class behavior. In this articles we will see, how to invoke a method dynamically at runtime.
Covariant return type example in java
The covariant return type allows narrowing down return type of the overridden method. This feature will help to avoid down casting on the client side. It allows programmer to program without the need of type checking and down casting. The covariant return type always works only for non-primitive return types.
If-then and if-then-else Statements in Java
If-else statement in java is used for conditional checks for decision making. You can have multiple hierarchies of if-else statements. Once any of the if or else-if condition satisfies it executes the block of statements corresponding to it
Switch-Case statement in Java
Switch case is another alternative for if-else statements. Switch case statement compares value in the object in the expression with the expressions associated with each case. A switch works only with primitive types like byte, short, char, and int and enumerated data types
How to Remove Duplicate in ArrayList using Comparator
This example shows how to remove duplicate from ArrayList using Comparator. The easiest way to remove duplicate is by passing the List to an Set. We will use Comparator to remove duplicate elements. Once you have the Set you can again pass it back to ArrayList.
Basic Java Language Constructs
Java keywords There are over 50 reserved keywords in Java programming language. Keywords are the language construct has…
History of Java Programming Language
Java Programming Language was developed with the combined effort from 5 great geeks, James Gosling, Patrick Naughton, Chris…
Introduction to Java, JVM and Writing Your Fist Java Program
Java is a high level, English like, object-oriented programming language with tons of
APIS
(application programming interface) for developing applications. Java is a platform independent language with support for performing complex computation, graphics, server and mobile application development. Java language syntax looks pretty much like C and C++, however there are some differences such as absence of pointers, allows writing object-oriented code. Learning Java is easy for a developer with basic C programming experience. How to Remove Duplicate Values From Java ArrayList
This example shows how to remove duplicate from ArrayList. The easiest way to remove duplicate is by passing the List to an Set. As set doesn't support duplicates it will omit the duplicate values. Once you have the Set you can again pass it back to ArrayList.
Java Collection Complete Tutorial with Examples
In this tutorial we’ll see the core collection interface available in java and their behavior. Examples in each section will show you the implementation and usage of various collection interfaces.
Java Exception Tutorial
Exception is an event during program execution that prevents the program from continuing normally.
Calculating factorial of number in Java
This example below accepts number from user and calculates factorial using while loop and prints it.
Drawing a pyramid using loops in Java
Below example prints star like pyramid structure using loop in java.
Java Constructor Tutorial and Examples
This is a tutorial explains how constructor works in Java. Constructor is an block of code which is executed before Object creation. Unlike methods constructors are getting called automatically.
CountDownLatch and Java Concurrency Example
CountDownLatch is one of the most usesful Java concept that helps tracking multiple threads execution. This is useful when you want one or more threads to wait until a set of operations being performed in other threads completes.