Generate temporary password is now a requirement on almost every website now-a-days. In case a user forgets the password, system generates a random password adhering to password policy of the company. Following example generates a random password adhering to following conditions − It should contain at least one capital case letter. It should contain at least one lower-case letter. .....
A final variable can be explicitly initialized only once. A reference variable declared final can never be reassigned to refer to a different object. However, the data within the object can be changed. So, the state of the object can be changed but not the reference. As an array is also an object and it is referred by a reference variable which if set as final then cannot be reassigned. Le.....
Java Byte streams are used to perform input and output of 8-bit bytes, whereas Java Character streams are used to perform input and output for 16-bit unicode. Though there are many classes related to character streams but the most frequently used classes are, FileReader and FileWriter. Though internally FileReader uses FileInputStream and FileWriter uses FileOutputStream but here the major .....
A word represents continous letters from a to z or A to Z. Using Regex that matches any letter from a-z and A-Z will suffice the need. We'll use the following regex pattern − , [a-z] matches any character from a to z. [A-Z] matches any character from A to Z. + matches 1 or more characters from the group. , This will produce the following result − ,
An enum in java represents a group of named constants. It can also have custom properties and methods. Let us look at an example. , This will produce the following result − , Here we've added a price as field and showPrice() as method to Enum. We've assign custom values to enum using its constructor.
Runtime Polymorphism in Java is achieved by Method overriding in which a child class overrides a method in its parent. An overridden method is essentially hidden in the parent class, and is not invoked unless the child class uses the super keyword within the overriding method. This method call resolution happens at runtime and is termed as Dynamic method dispatch mechanism. Let us look at.....
Following are the notable differences between HashTable and HashMap classes in Java. HashTable HashMap Synchronized HashTable is synchronized. HashMap is not synchronized. Thread Safe HashTable is thread safe. HashMap is not thread safe. Null objects HashTable does not allows null keys or null values. HashMap allows one null key and multiple null values. Performance HashTable is fas.....
Java compiler automatically creates a default constructor (Constructor with no arguments) in case no constructor is present in the java class. Following are the motive behind a default constructor. Create the Object Call the super class constructor() Initialize all the instance variables of the class object. Live Demo , ,
We can read whitespaces in a file by reading it in a string and then splitting based on "\\s+" pattern. It includes the whitespaces and \r\n characters. See the example below: Consider the following text file in classpath. , , This will produce the following result − ,
The architecture of the Internet is ever-changing due to continuous changes in the technologies as well as the nature of the service provided. The heterogeneity and vastness of the Internet make it difficult to describe every aspect of its architecture. The overall architecture can be described in three levels: Backbone ISP (Internet Service Provider)Regional ISPsClientsThe following diagra.....
Sign up now to get your own personalized profile!
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more