Java Swing Tutorial - Java Color.toString()








Syntax

Color.toString() has the following syntax.

public String toString()

Example

In the following code shows how to use Color.toString() method.

import java.awt.Color;
//  www  .  j  av  a 2s  .  co  m
public class Main {
  public static void main(String[] args) {
    Color myColor = Color.RED;          

    System.out.println(myColor.toString());
    
  }
}

The code above generates the following result.