MessageFormat parse() method in Java with Example : Set – 2
The parse() method of java.text.MessageFormat class is used to parse the string object starting from the passed parse position in the parse() method.
public Object parse(String source, ParsePosition pos)
Parameter: This method takes the following arguments as parameter.
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.
- 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 parse() method:
Parsed value are : 456 30.444 20.325
Parse position is Null Exception thrown : java.lang.NullPointerException