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

爱⌒轻易说出口 提交于 2020-01-11 11:36:29

问题


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


回答1:


Simply

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

Source: first match on Google.




回答2:


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.




回答3:


A question related to this was already asked:

square root character/symbol

Check out the post and see if this works for you. This site might also have some answers for you:

http://java2everyone.blogspot.com/2009/04/square-root-symbol-in-java.html



来源:https://stackoverflow.com/questions/15672161/print-a-square-root-symbol-%e2%88%9a-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!