import org.apache.hadoop.conf.Configuration; //create a configuration object Configuration conf = new Configuration(); //set a float property conf.setFloat("my.property", 3.14f); //get the value of the property float myFloatValue = conf.getFloat("my.property", 0.0f); //display the value System.out.println("The value of my.property is: " + myFloatValue);
import org.apache.hadoop.conf.Configuration; //create a configuration object Configuration conf = new Configuration(); //set a float property conf.set("my.property", "not a float"); //get the value of the property float myFloatValue = conf.getFloat("my.property", 0.0f); //display the value System.out.println("The value of my.property is: " + myFloatValue);In this example, we set a property called "my.property" with a non-float value of "not a float". When we retrieve its value using the getFloat method, it will return the default value of 0.0f since the property is not a valid float value. The value 0.0f is then displayed to the console. The package library for this method is org.apache.hadoop.conf, which is part of the Hadoop Core library.