Search code examples
javaandroidrect

Equivalent of Rectangle (JAVA) in Android


I need the clone method for Rectangle in Android.

Android has Rect instead of Rectangle. But it doesn' t have clone() method.

Is there any method equivalent with clone()


Solution

  • Rect has a copy constructor Rect(Rect) that you can use for cloning:

    Rect duplicatedRect = new Rect(originalRect);