Paint paint = new Paint(); paint.setTextSize(32); paint.setColor(Color.BLACK); String text = "Hello World"; Rect bounds = new Rect(); paint.getTextBounds(text, 0, text.length(), bounds);After executing this code, the bounds object will contain the coordinates of a rectangle that encloses the text "Hello World" drawn with the specified paint object. This code example belongs in the android.graphics package library since this is the package that contains the Paint class.