Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I assign the Euro or the Pound symbol to a variable?

Tags:

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
like image 498
Cintu Avatar asked Jan 27 '11 13:01

Cintu


People also ask

How do I type the 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.

How do you type the currency symbol?

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.

How do I get the euro symbol in Excel?

#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.

Do you put the € before or after?

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.


2 Answers

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);
    }
}
like image 52
Boris Pavlović Avatar answered Sep 17 '22 21:09

Boris Pavlović


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";
like image 30
Michael Berry Avatar answered Sep 18 '22 21:09

Michael Berry