java.lang Code Samples
- How do I create random number?
- How do I reverse a string by word?
- How do I check if a string contains a specific word?
- How do I execute other applications from Java?
- How do I convert decimal to octal?
- How do I convert other primitive data type into string?
- How do I get a part or a substring of a string?
- How do I get path / classpath separator?
- How do I create a console progress bar?
- How do I get operating system name and version?
- How do I determine whether a string is a palindrome?
- How do I know the length of a string?
- How do I convert varargs to an array?
- How do I check if a string is a valid number?
How do I know a class of an object?
For instance you have a collection of object in an list object and you want to do some logic base on the object class. This can easily be done using the instanceof operator. The operator returns true if an object is an instance of a class, if not it will return false.
The instanceof method is most likely used when implementing a equals(Object o) method of an object.