Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
639 views
in Technique[技术] by (71.8m points)

java - How to print an String variable as italicized text

I have the following statements inside my class:

String myName = "Joe";
System.out.println("My name is " +myName);

I need the value on the variable myName to be printed as italic text.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try:

System.out.println("33[3mText goes here33[0m");

Which will output italic text if your console supports it. You can use [1m for bold, etc. Play around with the different values of [nm.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...