在Java中实现typedef

Rog*_*ews 2 java

我有一个类型Time32用于泛型,Work<Time32>所以我做了一个类Time32.我也必须实施

typedef UInt(5) Time32
Run Code Online (Sandbox Code Playgroud)

这里UInt表示unsigned int.Java没有unsigned int,所以我创建了自己的类.

public class UInt 
{
    private final int size;
    public UInt(int x)
    {
       this.size=x;
    }

    public int getSize() 
    {
        return size;
    }
} 
Run Code Online (Sandbox Code Playgroud)

但我不明白我如何在java中实现typedef.请帮忙.谢谢.

我需要保留UInt类,因为我有一些其他变量将使用Uint UInt(20) LoadUInt(10) Force

A.H*_*.H. 5

由于Java中没有typdef,因此无法使用它们.最好的近似可能是这样的:

public class Time32 extends UInt {
    public Time32(){
        super(5);
    }
}
Run Code Online (Sandbox Code Playgroud)