FieldPosition equals Example

FieldPosition class equals example. This example shows you how to use equals method.


FieldPosition class equals example. public boolean equals(Object obj) Overrides equals

Here is the code
/*
 * @ # Equals.java
 * A class repersenting use to equals method 
 * of FieldPosition class in java.text package
 * version 17 June 2008
 * author Rose India 
 */

import java.text.*;
import java.math.*;

public class Equals {

    public static void main(String[] args) {
        // Get a default NumberFormat instance.
        NumberFormat numForm = NumberFormat.getInstance();

        // Format some decimals using the pattern supplied above.
        StringBuffer buffer = new StringBuffer(24);
        FieldPosition pos = new FieldPosition(NumberFormat.INTEGER_FIELD);
        FieldPosition pos1 = new FieldPosition(NumberFormat.INTEGER_FIELD);

        System.out.println("pos and pos1 is equal " + pos.equals(pos1));

        BigDecimal bd1 = new BigDecimal(22.222001D);
        buffer = numForm.format(bd1, buffer, pos);
        System.out.println("INTEGER portion is at: " + pos.getBeginIndex() +
                ", " + pos.getEndIndex());

        System.out.println("pos and pos1 is equal " + pos.equals(pos1));

    }
}

Output
pos and pos1 is equal true
INTEGER portion is at: 0, 2
pos and pos1 is equal false

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US