MessageFormat parseObject() method in Java with Example
The parseObject() method of java.text.MessageFormat class is used to parse the string object starting from the passed parse position in the parseObject() method.
public Object parseObject(String source, ParsePosition pos)
Parameter: This method takes the following arguments as parameter.
- source :- string over which parsing is going to perform.
- pos :- it is the starting index of parsing.
Return Value: This method returns array of object as an output.
Exception: This method throws NullPointerException if the parse position is null.
Below are the examples to illustrate the parseObject() method:
Parsed value are : 10.456 30.444 20.325
Parse position is Null Exception thrown : java.lang.NullPointerException
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.