Found 267 Articles for Java8

How to compile a java program

Akshaya Akki
Updated on 12-Sep-2023 02:07:51

32K+ Views

Compiling a Java program is very easy after JDK installation. Following are the steps −Open a command prompt window and go to the directory where you saved the java program. Assume it's C:\.Type 'javac MyFirstJavaProgram.java' and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption: The path variable is set).The file is compiled and you can see MyFirstJavaProgram.class file generated in the same folder.

How can we edit a java program?

Alankritha Ammu
Updated on 30-Jul-2019 22:30:21

556 Views

Java programs are simple text-based programs and can be edited using any text editor like notepad etc. The filename should be same as class name.

What are the key features of Java?

Debarpito Sarkar
Updated on 05-Sep-2022 12:08:11

4K+ Views

This article will help you understand what the key features of Java Programming language are. The Key features of Java Programming Language are − Java is Easy to Understand Java’s base is similar to that of C and C++ languages and it includes many important features of these languages. It removes many drawbacks and complexities of C or C++. So if one has good understanding of either C or C++, then Java language will be very familiar and easily understandable. Java is an object oriented programming language Object Oriented Programming (OOP) is an approach to standardize the programs by creating ... Read More

What does the method toArray() do?

karthikeya Boyini
Updated on 12-Mar-2020 12:16:49

661 Views

The toArray() method of the java.util.The ArrayList class returns an array containing all of the elements in this list in proper sequence (from first to the last element). This acts as a bridge between array-based and collection-based APIs.ExampleLive Demoimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String[] args) {       ArrayList arrlist = new ArrayList(5);       arrlist.add(20);       arrlist.add(40);       arrlist.add(10);       arrlist.add(15);       arrlist.add(25);       for (Integer number : arrlist) {          System.out.println("Number = " + number);       ... Read More

How to convert an input stream to byte array in java?

Syed Javed
Updated on 06-Mar-2020 05:07:10

1K+ Views

The InputStream class in Java provides read() method. This method accepts a byte array and it reads the contents of the input stream to the given byte array.ExampleLive Demoimport java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; public class StreamToByteArray {     public static void main(String args[]) throws IOException{            InputStream is = new BufferedInputStream(System.in);        byte [] byteArray = new byte[1024];        System.out.println("Enter some data");        is.read(byteArray);              String s = new String(byteArray);        System.out.println("Contents of the byte stream are :: "+ s);   ... Read More

What is a Multidimensional array in Java?

Monica Mona
Updated on 07-Mar-2024 16:48:43

2K+ Views

In Java, a multi-dimensional array is nothing but an array of arrays.2D array − A two-dimensional array in Java is represented as an array of one-dimensional arrays of the same type. Mostly, it is used to represent a table of values with rows and columns −Int[][] myArray = {{10, 20, 30}, {11, 21, 31}, {12, 22, 32} }In short, a two-dimensional array contains one-dimensional arrays of elements. It is represented by two indices where the first index denotes the position of the array and the second index represents the position of the element within that particular array − Example ... Read More

What is the character wrapper class and its methods in Java?

Syed Javed
Updated on 30-Jul-2019 22:30:22

5K+ Views

The Character class of the java.lang package wraps a value of the primitive datatype char. It offers a number of useful class (i.e., static) methods for manipulating characters. You can create a Character object with the Character constructor. Character ch = new Character('a'); Following are the notable methods of the Character class. 1 isLetter() Determines whether the specified char value is a letter. 2 isDigit() Determines whether the specified char value is a digit. 3 isWhitespace() Determines whether the specified char value is white space. 4 isUpperCase() Determines ... Read More

Advertisements