Samual Sam has Published 2310 Articles

Assigning values to static final variables in java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 15:45:03

936 Views

In java, a non-static final variable can be assigned a value at two places.At the time of declaration.In constructor.ExampleLive Demopublic class Tester {    final int A;    //Scenario 1: assignment at time of declaration    final int B = 2;    public Tester() {       //Scenario ... Read More

End User Database

Samual Sam

Samual Sam

Updated on 18-Jun-2020 15:35:09

2K+ Views

The end user is usually not concerned about the transaction or operations done at various levels and is only aware of the product which may be a software or an application. Therefore, this is a shared database which is specifically designed for the end user, just like different levels’ managers. ... Read More

Conversion of Set To Stream in Java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 15:31:03

909 Views

Being a type of Collection, we can convert a set to Stream using its stream() method.ExampleLive Demoimport java.util.HashSet; import java.util.Set; import java.util.stream.Stream; public class Tester {    public static void main(String args[]) {       Set set = new HashSet();       set.add("a");       ... Read More

Copying file using FileStreams in Java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 15:26:45

347 Views

This example shows how to copy the contents of one file into another file using read & write methods of FileStreams classes.ExampleLive Demoimport java.io.*; public class Main {    public static void main(String[] args) throws Exception {       BufferedWriter out1 = new BufferedWriter(new FileWriter("srcfile"));       ... Read More

Comparison of autoboxed integer object in Java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 14:52:30

342 Views

When we assigned an int to Integer object, it is first converted to an Integer Object and then assigned. This process is termed as autoboxing. But there are certain things which you should consider while comparison of such objects using == operator. See the below example first.ExampleLive Demopublic class Tester ... Read More

Compilation and execution of Java Program

Samual Sam

Samual Sam

Updated on 18-Jun-2020 14:46:45

18K+ Views

Let us look at a simple code first that will print the words Hello World.ExampleLive Demopublic class MyFirstJavaProgram {    /* This is my first java program.        * This will print 'Hello World' as the output        */    public static void main(String ... Read More

Collections in Java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 14:20:18

573 Views

Prior to Java 2, Java provided ad hoc classes such as Dictionary, Vector, Stack, and Properties to store and manipulate groups of objects. Although these classes were quite useful, they lacked a central, unifying theme. Thus, the way that you used Vector was different from the way that you used ... Read More

Can we override private methods in Java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 13:35:44

1K+ Views

Ideally No. But, using the tricky code, a subclass can override a private method as well. See the example below −ExampleLive Democlass A {    private void display() {       System.out.println("A.display");    }     public void callDisplay() {       System.out.println("A.callDisplay");       display();   ... Read More

Character Stream vs Byte Stream in Java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 13:25:51

10K+ Views

Byte StreamsJava byte streams are used to perform input and output of 8-bit bytes. Though there are many classes related to byte streams but the most frequently used classes are, FileInputStream and FileOutputStream. Following is an example which makes use of these two classes to copy an input file into ... Read More

Check if a file is hidden in Java

Samual Sam

Samual Sam

Updated on 18-Jun-2020 13:15:46

238 Views

The java.io.File class provides useful methods on file. This example shows how to check a file hidden or not by using the file.isHidden() method of File class.Exampleimport java.io.File; public class Main {    public static void main(String[] args) {       File file = new File("C:/java.txt");     ... Read More

Advertisements