

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Removing a Preference from a Preference Node in Java
In order to remove a preference from a preference node in Java, we use the remove() method. The remove method() removes all the values associated with the specified key in the preference node.
Declaration − The java.util.prefs.Preferences.remove() method is declared as follows −
public abstract void remove (String key)
where key is the key whose preference is to be removed
The remove methods throws the following exceptions −
NullPointerException | This exception occurs when the key is null |
IllegalStateException | This exception is thrown when the ancestor node is removed by the removeNode() method. |
Let us see a program to remove the preference from a preference node −
Example
import java.util.prefs.Preferences; public class Example { public static void main(String[] args) throws Exception { // obtains the user preference node for java.lang Preferences pre = Preferences.userNodeForPackage(String.class); // Remove a preference in the node final String name = "name"; pre.remove(name); } }
Output
Dec 26, 2018 6:00:21 AM java.util.prefs.FileSystemPreferences$1 run INFO: Created user preferences directory.
- Related Questions & Answers
- Determine if a Preference Node exists in Java
- Differentiate between preference shares and debenture.
- What is Risk Preference? (Financial Management)
- Define preference shares used in financial management.
- What are the features of Preference Shares?
- What are the different types of Preference Shares?
- How to calculate the yield of Preference Shares?
- Removing a node in a Javascript Tree
- How to use shared preference in Android between activities?
- How are redeemable and non-redeemable preference shares valued?
- What is meant by Time Preference or Time Value of Money?
- Removing the specified node from the LinkedList in C#?
- Java program for removing n-th character from a string
- Get an element from a Stack in Java without removing it
- Removing a specific substring from a string in JavaScript
Advertisements