Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print a square root symbol (√) in java [duplicate]

I am just wondering how do you print a square root(√) character in Java? I am assuming you use its unicode or something?

like image 523
jackgerrits Avatar asked Jul 17 '26 17:07

jackgerrits


2 Answers

Simply

System.out.println("Square Root: \u221A");

Source: first match on Google.

like image 118
jessechk Avatar answered Jul 20 '26 20:07

jessechk


Here's the unicode number for it: http://www.fileformat.info/info/unicode/char/221a/index.htm

And this prints it out to a file for me:

package com.sandbox;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;

public class Sandbox {

    public static void main(String[] args) throws ParseException, IOException {
        FileUtils.write(new File("out.txt"), "\u221A", "UTF8");
    }


}

When I open that file, it has the square root symbol in it.

like image 30
Daniel Kaplan Avatar answered Jul 20 '26 22:07

Daniel Kaplan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!