LoginSignup
0
0

More than 1 year has passed since last update.

upcast

Posted at

入力値チェックのためにbyte→longのように大きな器に移し替えることを
upcastと呼ぶ

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;

/**
 *
 * @author java
 */
public class SampleProject {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        byte b = 100;
        long l = b;    //up cast
        System.out.println(l);
        if (l>Byte.MAX_VALUE || l<Byte.MIN_VALUE) {
            System.out.println("max erro or min error");
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0