Maruthi Krishna has Published 951 Articles

Can you assign an Array of 100 elements to an array of 10 elements in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 12:14:32

3K+ Views

In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using ... Read More

What are the best practices to keep in mind while using packages in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 12:11:58

561 Views

You can create the .class files of all the Java classes and interfaces related to each other in one folder automatically by declaring them under same package. A package is nothing but a directory storing classes and interfaces of a particular concept.Creating a packageYou can create a package and add ... Read More

How to read a single character using Scanner class in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:52:39

2K+ Views

From Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads all the primitive data types and Strings (from the given source) token by token using regular expressions. By default, whitespace is considered as the delimiter (to break the data into tokens).Reading a ... Read More

Difference between import and package in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:50:24

2K+ Views

In Java classes and interfaces related to each other are grouped under a package. Package is nothing but a directory storing classes and interfaces of a particular concept. For example, all the classes and interfaces related to input and output operations are stored in java.io package.Creating a packageYou can group ... Read More

How do you print the content of an array in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:49:24

441 Views

In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using ... Read More

Can you use a switch statement around an enum in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 11:48:07

907 Views

Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc.enum Days {    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }You can also define an enumeration with ... Read More

Difference between the byte stream and character stream classes in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 10:37:19

3K+ Views

Java provides I/O Streams to read and write data where, a Stream represents an input source or an output destination which could be a file, i/o devise, other program etc.Based on the data they handle there are two types of streams −Byte Streams − These handle data in bytes (8 ... Read More

Write a program to print message without using println() method in java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 10:34:27

5K+ Views

The println() method of the System class accepts aStringas parameter an prints the given String on the console.Examplepublic class PrintData {    public static void main(String args[]) {       System.out.println("Hello how are you");    } }OutputHello how are youIn addition to this you can print data on the ... Read More

Is it possible to synchronize the string type in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 10:33:35

1K+ Views

A thread is a piece of code (under execution) in a program, which executes a sub task of the process independently. independent process.In other words, a thread is a light weight process which executes a piece of code independently.Thread synchronizationIf a process has multiple threads running independently at the same ... Read More

Why String class is popular key in a HashMap in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Jul-2020 10:32:54

3K+ Views

A map is a collection in Java which stores key value pairs. The keys of this must not be null and each key should point to only one value. It is represented by the Map interface of java.util package. There are various classes which provides implementation to this interface.The HashMap ... Read More

Advertisements