zoukankan      html  css  js  c++  java
  • String

    1、trim() :删除字符串两端的空白字符返回一个新字符串。字符 ' ' 、 、f、 、 被称为空白字符。

    2、从控制台读取字符串

    next( ) : 读取以空白字符结束的字符串

    nextLine( ) : 读取一整行文本。以按下回车键为结束标志的字符串。

    3、charAt( index ) 返回字符串s中指定的字符

    4、字符串比较

    equals( )

    equalsIgnoreCase( )

    compareTo( ) :返回的实际值是根据从左到右数第一个不同字符之间的距离得出来  

    compareToIngnoreCase( )

    startsWith( ) : 字符串以特定的前缀开始 返回true

    endsWith( )

    contains( )

    substring( ) 从字符串中提取子串

    5、返回字符串中的字符或子串

    indexOf

    lastIndexOf

    6、格式化控制台输出

    System.out.printf

    格式标志

    7、最小化数值错误

    涉及浮点数的数值误差是无法避免的,因为浮点数在计算机中本身就是近似表示的。

    public class test {

    public static void main(String[] args) {
    //0.01~1.0的数列之和
    float sum = 0;
    for(float i=0.01f; i<=1.0f;i=i+0.01f) {
    sum += i;
    System.out.print(i + " ");
    System.out.println(sum + " ");
    }
    System.out.println("sum = " + sum); //sum = 50.499985
    }
    }

    总结:从小到大添加数字 比 从大到小添加数字精确度稍高

    8、

    拼命敲
  • 相关阅读:
    codeforces C. No to Palindromes!
    codeforces D. Pashmak and Parmida's problem
    codeforces C. Little Pony and Expected Maximum
    codeforces D. Count Good Substrings
    codeforces C. Jzzhu and Chocolate
    codeforces C. DZY Loves Sequences
    codeforces D. Multiplication Table
    codeforces C. Painting Fence
    hdu 5067 Harry And Dig Machine
    POJ 1159 Palindrome
  • 原文地址:https://www.cnblogs.com/wuyuwuyueping/p/9552827.html
Copyright © 2011-2022 走看看