How do I get my screen size?

package org.kodejava.awt;

import java.awt.*;

public class ScreenSizeExample {
    public static void main(String[] args) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

        System.out.println("Screen Width: " + screenSize.getWidth());
        System.out.println("Screen Height: " + screenSize.getHeight());
    }
}

The output of the code snippet above:

Screen Width: 2560.0
Screen Height: 1080.0
Wayan

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.