Java Articles

Page 436 of 450

Java is also not pure object-oriented like c++

Pythonista
Pythonista
Updated on 30-Jul-2019 455 Views

the main() method in Java code is itself inside a class. The static keyword lets the main() method which is the entry point of execution without making an object but you need to write a class. In C++, main() is outside the class and writing class it self is not mandatory. Hence, C++ is not a pure object oriented language bu Java is a completely object oriented language.

Read More

compareTo() definition mistake?

Pythonista
Pythonista
Updated on 30-Jul-2019 220 Views

The example works correctly. The compareTo() method is called by a string object and takes another string object as argument. The return value is integer and is difference in Unicode values of characters of respective strings when they are not equal. The value can be -ve, 0 or +ve.

Read More

Sum of all proper divisors of a natural number in java

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 568 Views

Following is the Java program which prints all the sum of all the divisors of a given number.

Read More

Sum of all proper divisors of a natural number in java

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 568 Views

Following is the Java program which prints all the sum of all the divisors of a given number.

Read More

branching statement in Java

Kumar Varma
Kumar Varma
Updated on 30-Jul-2019 835 Views

Java programming language provides following types of decision making or branching statements.Java programming language provides following types of decision making statements.Sr.No.Statement & Description1if statementAn if statement consists of a boolean expression followed by one or more statements.2if...else statementAn if statement can be followed by an optional else statement, which executes when the boolean expression is false.3nested if statementYou can use one if or else if statement inside another if or else if statement(s).4switch statementA switch statement allows a variable to be tested for equality against a list of values.

Read More

branching statement in Java

Kumar Varma
Kumar Varma
Updated on 30-Jul-2019 835 Views

Java programming language provides following types of decision making or branching statements.Java programming language provides following types of decision making statements.Sr.No.Statement & Description1if statementAn if statement consists of a boolean expression followed by one or more statements.2if...else statementAn if statement can be followed by an optional else statement, which executes when the boolean expression is false.3nested if statementYou can use one if or else if statement inside another if or else if statement(s).4switch statementA switch statement allows a variable to be tested for equality against a list of values.

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

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 194 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 314 Views

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

Read More
Showing 4351–4360 of 4,495 articles
« Prev 1 434 435 436 437 438 450 Next »
Advertisements