Java Articles

Page 437 of 450

Creating multiple Java objects by one type only

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 2K+ Views

You can create a List of object easily. Consider the following example, where I'll create an array of Employee objects and print their details in a for loop. import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; public class Tester implements Cloneable { private int data; public int getData() { return data; } public void setData(int data) { this.data = data; } public Tester(int data){ ...

Read More

Creating multiple Java objects by one type only

Ankitha Reddy
Ankitha Reddy
Updated on 30-Jul-2019 2K+ Views

You can create a List of object easily. Consider the following example, where I'll create an array of Employee objects and print their details in a for loop. import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; public class Tester implements Cloneable { private int data; public int getData() { return data; } public void setData(int data) { this.data = data; } public Tester(int data){ ...

Read More

How to write string functions in Java?

Pythonista
Pythonista
Updated on 30-Jul-2019 201 Views

1) take a string from the user and check contains atleast one digit or not:Extract character array from string using toCharArray() method. Run a for loop over each character in array and test if it is a digit by static method isDigit() of character classpublic static boolean chkdigit(String str) { char arr[]=str.toCharArray(); for (char ch:arr) { if (Character.isDigit(ch)) { return true; } } return false; }2.) take ...

Read More

What does the bitwise left shift operator do in Java?

Monica Mona
Monica Mona
Updated on 30-Jul-2019 322 Views

The left operand value is moved left by the number of bits specified by the right operand.Example: A

Read More

What does the bitwise right shift operator do in Java?

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 30-Jul-2019 431 Views

The left operand value is moved right by the number of bits specified by the right operand.Example: A >> 2 = 15 means 1111.

Read More

What is the difference between >> and >>> operators in Java?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 2K+ Views

>> Binary Right ShiftThe left operand value is moved right by the number of bits specified by the right operand.>>> Shift right zero fillThe left operand value is moved right by the number of bits specified by the right operand and shifted values are filled up with zeros.

Read More

What is the difference between the size of ArrayList and length of Array in Java?

Srinivas Gorla
Srinivas Gorla
Updated on 30-Jul-2019 2K+ Views

ArrayList doesn't have length() method, the size() method of ArrayList provides the number of objects available in the collection.Array has length property which provides the length or capacity of the Array. It is the total space allocated during the initialization of the array.

Read More

How can we edit a java program?

Alankritha Ammu
Alankritha Ammu
Updated on 30-Jul-2019 823 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.

Read More

How can we edit a java program?

Alankritha Ammu
Alankritha Ammu
Updated on 30-Jul-2019 823 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.

Read More

What is JAVA_HOME variable in Java Environment?

Anjana
Anjana
Updated on 30-Jul-2019 558 Views

JAVA_HOME refers to jdk/bin directory. It is used by a java based application.

Read More
Showing 4361–4370 of 4,498 articles
« Prev 1 435 436 437 438 439 450 Next »
Advertisements