2405/what-are-optional-parameters-in-java
How can we use optional parameters in Java? What are the specifications that should be kept in mind regarding optional parameters?
Using three dots:
public void move(Object... x) { String first = x.length > 0 ? (String)x[0] : "Hello"; int duration = x.length > 1 ? Integer.parseInt((String) x[1]) : 888; } move("Hello", ); move("Hello", 23);
According to Effective Java, chapter 4, page 73, ...READ MORE
equals() must define an equivalent relation and ...READ MORE
A daemon thread is a thread that is doing ...READ MORE
There are different ways you could do this ...READ MORE
Yes; the Java Language Specification writes: In the Java ...READ MORE
You can use split() method. str = "Hello ...READ MORE
import java.io.IOException; public class chkClearScreen { public static void ...READ MORE
From Java 1.5 you can use the String.format method. ...READ MORE
Java 8 Lambda Expression is used: String someString ...READ MORE
String[] source = new String[] { "a", ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.