-5

say I have a string "How are you?" How would I convert just the word "you" into italics.

PS, I am a beginner so please don't incorporate advanced programming.

user3370908
  • 29
  • 1
  • 7
  • Please give more detail. Where would you like this in italic? Have you tried anything already? If you have, do you have any errors? We need more information. – Walshy Feb 04 '16 at 23:51
  • This user hardly accepts solution. – user3437460 Feb 04 '16 at 23:56
  • You cannot. A Java string is just a sequence of letters. They don't have a physical representation until printed, at which point a particular font of applied, by whatever medium is used. If printing to a console (command-prompt), you cannot. If printing to a GUI app, or when rendered by a browser in an HTML page, you can, but those are just two VERY distinct examples, and how to accomplish it is totally different. – Andreas Feb 05 '16 at 00:24

1 Answers1

1

If your text is the label for a UI element in JFC/Swing you can use HTML like:

String labelText = "How are <i>you</i>?";

If it's for a console application, then you'd first need a console that supports italic text (I don't think there is support for italics on the console).

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249