I need to assign the Euro or the Pound symbol to a variable. How can i do this?
String euro = "";// What i have to write here??
System.out.println(euro);// I need to print euro symbol
The Euro sign or symbol (€) is not difficult to insert into a Microsoft Word document. To type the Euro symbol (€) in Microsoft Word for Windows, press CRTL + ALT + E.
123 key in the lower-left corner of the keyboard. In the second row of numbers and symbols, press and hold your finger on the dollar-sign key. Above your finger, a box will pop up showing several currency symbols; these include the peso, the euro, the cent sign, the pound sterling and the yen.
#1 – Using Shortcut Key We can use a shortcut key to insert the “EURO” symbol in the cell of MS Excel. The shortcut key is “Alt+0128.” We need to press the keys for “0”, “1”, “2,” and “8” while pressing the “Alt” key to enter the “EURO” symbol in the cell.
In Statistics Explained articles the symbol '€' should be used for euro in the text if it is followed by a number. This applies also to graphs and tables. It should be placed before the figure: €30.
public class ExampleEuroPound {
public static void main(String args[]){
String euro = "\u20ac";
String pound = "\u00a3";
System.out.println("pound = " + pound);
System.out.println("euro = " + euro);
}
}
If you can't type it then you could use the unicode value for euro:
String euro = "\u20AC";
System.out.println(euro);
If you're doing this however, best practice is to comment it and / or save it as a constant field for clarity (unexplained unicode literals in code are just plain confusing!):
public static final String POUND = "\u00A3";
public static final String EURO = "\u20AC";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With