Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Java Articles
Page 437 of 450
Creating multiple Java objects by one type only
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 MoreCreating multiple Java objects by one type only
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 MoreHow to write string functions in Java?
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 MoreWhat does the bitwise left shift operator do in Java?
The left operand value is moved left by the number of bits specified by the right operand.Example: A
Read MoreWhat does the bitwise right shift operator do in Java?
The left operand value is moved right by the number of bits specified by the right operand.Example: A >> 2 = 15 means 1111.
Read MoreWhat is the difference between >> and >>> operators in Java?
>> 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 MoreWhat is the difference between the size of ArrayList and length of Array in Java?
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 MoreHow can we edit a java program?
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 MoreHow can we edit a java program?
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 MoreWhat is JAVA_HOME variable in Java Environment?
JAVA_HOME refers to jdk/bin directory. It is used by a java based application.
Read More