0
package Jai

public class potpie {

    public static void main(String[] arg){
        String s = "Hey";
        System.out.println(s);
    }
}

In the output, I want that the string is in bold form

FuSsA
  • 4,223
  • 7
  • 39
  • 60
  • 4
    You can't change the font for the console output. – AndrejH May 29 '18 at 13:14
  • 2
    the "font for a String" ? Strings don't have a font – Stultuske May 29 '18 at 13:15
  • @AndrejHafner [Are you sure?](https://stackoverflow.com/questions/5762491/how-to-print-color-in-console-using-system-out-println) – Rafalon May 29 '18 at 13:16
  • @Rafalon Absolutely. – AndrejH May 29 '18 at 13:16
  • @AndrejHafner going through [shakram02's answer](https://stackoverflow.com/a/45444716/7831383) to previously linked question, it seems you can change color, weight, underline, background and combination of those using ANSI escape codes (as long as you're not on windows apparently) – Rafalon May 29 '18 at 13:43
  • Also, several comments there mention a windows console emulator that supports fonts: cmder ([cmder.net](http://cmder.net)) – Rafalon May 29 '18 at 13:50

3 Answers3

1

It's a console output. Unfortunately there is no way to do it..

FuSsA
  • 4,223
  • 7
  • 39
  • 60
0

try this

public static void main(String[] args){
 String yourText = "\033[1mThis is a BOLD line\033[0m";
 System.out.println(yourText);
}
  • @BrandonZamudio It uses [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code), as used in [shakram02's answer](https://stackoverflow.com/a/45444716/7831383) to the question [How to print color in console using system.out.println?](https://stackoverflow.com/questions/5762491/how-to-print-color-in-console-using-system-out-println) – Rafalon May 29 '18 at 13:53
  • Right @Rafalon :) – Pradeep Kmvsoftwares May 30 '18 at 14:12
0

In this case of yours, where you are trying to print something to the console, you cannot actually change the font.

You can sure change colour, weight of the font you want to print on to the console using ANSI ESCAPE CODES. Using this you can print bold text to the console.

Sikakollu
  • 56
  • 6