国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

JavaAPI

Nov 19, 2016 am 10:21 AM
java

》JavaAPI

  文檔注釋可以在:類,常量,方法上聲明

  文檔注釋可以被javadoc命令所解析并且根據內容生成手冊

package cn.fury.se_day01;
/**
 * 文檔注釋可以在:類,常量,方法上聲明
 * 文檔注釋可以被javadoc命令所解析并且根據內容生成手冊
 * 這個類用來測試文檔注釋
 * @author soft01
 * @version 1.0
 * @see java.lang.String
 * @since jdk1.0
 *
 */
public class APIDemo {
    public static void main(String[] args){
        System.out.println(sayHello("fury"));
    }
    /**
     * 問候語,在sayHello中被使用
     */
    public static final String INFO = "你好!";
    /**
     * 將給定的用戶名上添加問候語
     * @param name 給定的用戶名
     * @return  帶有問候語的字符串
     */
    public static String sayHello(String name){
        return INFO+name;
    }
}

測試代碼

》字符串是不變對象:字符串對象一旦創(chuàng)建,內容就不可更改

  》》字符串對象的重用

  **要想改變內容一定會創(chuàng)建新對象**

  TIP: 字符串若使用字面量形式創(chuàng)建對象,會重用以前創(chuàng)建過的內容相同的字符串對象。

  重用常量池中的字符串對象:就是在創(chuàng)建一個字符串對象前,先要到常量池中檢查是否這個字符串對象之前已經創(chuàng)建過,如果是就會進行重用,如果否就會重新創(chuàng)建

package cn.fury.test;

public class Test{
    public static void main(String[] args) {
        String s1 = "123fury"; //01
        String s2 = s1; //02
        String s3 = "123" + "fury"; //03
        String s4 = "warrior";
        System.out.println(s1 == s2);
        System.out.println(s3 == s1);
        System.out.println(s4 == s1);
    }
}

/**
 * 01 以字面量的形式創(chuàng)建對象:會重用常量池中的字符串對象
 * 02 賦值運算:是進行的地址操作,所以會重用常量池中的對象
 * 03 這條語句編譯后是:String s3 = "123fury";
 */

字符串對象的重用
package cn.fury.se_day01;
/**
 * 字符串是不變對象:字符串對象一旦創(chuàng)建,內容是不可改變的,
 *         **要想改變內容一定會創(chuàng)建新對象。**
 * 
 * 字符串若使用字面量形式創(chuàng)建對象,會重用以前創(chuàng)建過的內容相同的字符串對象。
 * @author soft01
 *
 */
public class StringDemo01 {
    public static void main(String[] args) {
        String s1 = "fury123";
//        字面量賦值時會重用對象
        String s2 = "fury123";
//        new創(chuàng)建對象時則不會重用對象
        String s3 = new String("fury123");
        /*
         * java編譯器有一個優(yōu)化措施,就是:
         * 若計算表達式運算符兩邊都是字面量,那么編譯器在生成class文件時
         * 就會將結果計算完畢并保存到編譯后的class文件中了。
         * 
         * 所以下面的代碼在class文件里面就是:
         * String s4 = "fury123";
         */
        String s4 = "fury" + "123"; //01
        String s5 = "fury";
        String s6 = s5 + "123"; //02
        String s7 = "fury"+123; //01
        String s8 = "fu"+"r"+"y"+12+"3";
        
        String s9 = "123fury";
        String s10 = 12+3+"fury";  //編譯后是String s10 = "15fury";
        String s11 = '1'+2+'3'+"fury"; //03
        String s12 = "1"+2+"3"+"fury";
        String s13 = 'a'+26+"fury"; //04
        
        System.out.println(s1 == s2); //true
        System.out.println(s1 == s3); //false
        System.out.println(s1 == s4); //true
        System.out.println(s1 == s6); //false
        System.out.println(s1 == s7); //true
        System.out.println(s1 == s8); //true
        System.out.println(s9 == s10); //false
        System.out.println(s9 == s11); //false
        System.out.println(s9 == s12); //true
        System.out.println(s9 == s13); //true
        /*
         * 用來驗證03的算法
         */
        int x1 = '1';
        System.out.println(x1);
        System.out.println('1' + 1);
        /*
         * 用來驗證04的算法
         */
        int x2 = 'a';
        System.out.println(x2);
        System.out.println('a' + 26);
//        System.out.println(s10);
    }
}

/*
 * 01 編譯完成后:String s4 = "fury123";  因此會重用對象
 * 02 不是利用字面量形式創(chuàng)建對象,所以不會進行重用對象
 * 03 '1'+2  的結果不是字符串形式的12,而是字符1所對應的編碼加上2后的值
 * 04 'a'+26 的結果是字符a所對應的編碼值再加上26,即:123
 */

list

  》》字符串長度

    中文、英文字符都是按照一個長度進行計算

package cn.fury.se_day01;
/**
 * int length()
 * 該方法用來獲取當前字符串的字符數量,
 * 無論中文還是英文每個字符都是1個長度
 * @author soft01
 *
 */
public class StringDemo02 {
    public static void main(String[] args) {
        String str = "hello fury你好Java";
        System.out.println(str.length());
        
        int [] x = new int[3];
        System.out.println(x.length);
    }
}

字符串的長度

  》》子串出現的位置

public int indexOf(String str) {
        return indexOf(str, 0);
    }

    /**
     * Returns the index within this string of the first occurrence of the
     * specified substring, starting at the specified index.
     *
     * <p>The returned index is the smallest value <i>k</i> for which:
     * <blockquote><pre class="brush:php;toolbar:false">
     * <i>k</i> &gt;= fromIndex {@code &&} this.startsWith(str, <i>k</i>)
     * 
* If no such value of k exists, then {@code -1} is returned. * * @param str the substring to search for. * @param fromIndex the index from which to start the search. * @return the index of the first occurrence of the specified substring, * starting at the specified index, * or {@code -1} if there is no such occurrence. */ public int indexOf(String str, int fromIndex) { return indexOf(value, 0, value.length, str.value, 0, str.value.length, fromIndex); } 方法解釋
package cn.fury.se_day01;
/**
 * int indexOf(String str)
 * 查看給定字符串在當前字符串中的位置
 * 首先該方法會使用給定的字符串與當前字符串進行全匹配
 * 當找到位置后,會將給定字符串中第一個字符在當前字符串中的位置返回;
 * 沒有找到就返回  **-1**
 * 常用來查找關鍵字使用
 * @author soft01
 *
 */
public class StringDemo03 {
    public static void main(String[] args) {
        /*
         * java編程思想:  Thinking in Java
         */
        String str = "thinking in java";
        int index = str.indexOf("java");
        System.out.println(index);
        index = str.indexOf("Java");
        System.out.println(index);
        /*
         * 重載方法:
         *         從給定位置開始尋找第一次出現給定字符串的位置
         */
        index = str.indexOf("in", 3);
        System.out.println(index);
        /*
         * int lastIndexOf(String str)
         * 返回給定的字符串在當前字符串中最后一次出現的位置
         */
        int last = str.lastIndexOf("in");
        System.out.println(last);
    }
}

方法應用

  》》截取部分字符串

    String substring(int start, int end)

Open Declaration   String java.lang.String.substring(int beginIndex, int endIndex)


Returns a string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex. 

Examples: 

 "hamburger".substring(4, 8) returns "urge"
 "smiles".substring(1, 5) returns "mile"
 
Parameters:beginIndex the beginning index, inclusive.endIndex the ending index, exclusive.Returns:the specified substring.Throws:IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.

方法解釋
package cn.fury.se_day01;
/**
 * String substring(int start, int end)
 * 截取當前字符串的部分內容
 * 從start處開始,截取到end(但是不含有end對應的字符)
 * 
 * java API有個特點,凡是使用兩個數字表示范圍時,通常都是“含頭不含尾”
 * @author soft01
 *
 */
public class StringDemo04 {
    public static void main(String[] args) {
        String str = "www.oracle.com";
        
        //截取oracle
        String sub = str.substring(4, 10);
        System.out.println(sub);
        
        /*
         * 重載方法,只需要傳入一個參數,從給定的位置開始連續(xù)截取到字符串的末尾
         */
        sub = str.substring(4);
        System.out.println(sub);
    }
}

方法應用
package cn.fury.test;

import java.util.Scanner;

/**
 * 網址域名截取
 * @author Administrator
 *
 */
public class Test{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("請輸入網址:");
        String s1 = sc.nextLine();
        int index1 = s1.indexOf(".");
        int index2 = s1.indexOf(".", index1 + 1);
        String s2 = s1.substring(index1 + 1, index2);
        System.out.println("你輸入的網址是:");
        System.out.println(s1);
        System.out.println("你輸入的網址的域名為:");
        System.out.println(s2);
    } 
}

實際應用

  》》去除當前字符串中兩邊的空白

    String trim()
    去除當前字符串中兩邊的空白

Open Declaration   String java.lang.String.trim()


Returns a string whose value is this string, with any leading and trailing whitespace removed. 

If this String object represents an empty character sequence, or the first and last characters of character sequence represented by this String object both have codes greater than &#39;\u005Cu0020&#39; (the space character), then a reference to this String object is returned. 

Otherwise, if there is no character with a code greater than &#39;\u005Cu0020&#39; in the string, then a String object representing an empty string is returned. 

Otherwise, let k be the index of the first character in the string whose code is greater than &#39;\u005Cu0020&#39;, and let m be the index of the last character in the string whose code is greater than &#39;\u005Cu0020&#39;. A String object is returned, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(k, m + 1). 

This method may be used to trim whitespace (as defined above) from the beginning and end of a string.
Returns:A string whose value is this string, with any leading and trailing white space removed, or this string if it has no leading or trailing white space.

方法解釋
package cn.fury.se_day01;
/**
 * String trim()
 * 去除當前字符串中兩邊的空白
 * @author soft01
 *
 */
public class StringDemo06 {
    public static void main(String[] args) {
        String str1 = "  Keep Calm and Carry on.        ";    
        System.out.println(str1);
        String str2 = str1.trim();  //01
        System.out.println(str2);
        System.out.println(str1 == str2);  //02
    }
}

/*
 * 01 改變了內容,因此創(chuàng)建了新對象,所以02的輸出結果為false
 */

方法應用

  》》查看指定位置的字符

    char charAt(int index)

    返回當前字符串中給定位置處對應的字符

Open Declaration   char java.lang.String.charAt(int index)


Returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array indexing. 

If the char value specified by the index is a surrogate, the surrogate value is returned.

Specified by: charAt(...) in CharSequence
Parameters:index the index of the char value.Returns:the char value at the specified index of this string. The first char value is at index 0.Throws:IndexOutOfBoundsException - if the index argument is negative or not less than the length of this string.

方法解釋
package cn.fury.se_day01;
/**
 * char charAt(int index)
 *  返回當前字符串中給定位置處對應的字符
 * @author soft01
 *
 */
public class StringDemo07 {
    public static void main(String[] args) {
        String str = "Thinking in Java";
//        查看第10個字符是什么?
        char chr = str.charAt(9);
        System.out.println(chr);
        
        /*
         * 檢查一個字符串是否為回文?
         */
    }
}

方法應用
package cn.fury.test;

import java.util.Scanner;

public class Test{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("請輸入一個字符串(第三個字符必須是字符W):");
        while(true){
            String s1 = sc.nextLine();
            if(s1.charAt(2) == &#39;W&#39;){
                System.out.println("輸入正確");
                break;
            }else{
                System.out.print("輸入錯誤,請重新輸入。");
            }
        }
    } 
}

實際應用
package cn.fury.se_day01;
/*
 * 判斷一個字符串是否是回文數:個人覺得利用StringBuilder類中的反轉方法reverse()更加簡單
 */
public class StringDemo08 {
    public static void main(String[] args) {
        /*
         * 上海的自來水來自海上
         * 思路:
         *         正數和倒數位置上的字符都是一致的,就是回文
         */
        String str = "上海自水來自海上";
        System.out.println(str);
//        myMethod(str);
        teacherMethod(str);
    }

    private static void teacherMethod(String str) {
        for(int i = 0; i < str.length() / 2; i++){
            if(str.charAt(i) != str.charAt(str.length() - 1 - i)){
                System.out.println("不是回文");
                /*
                 * 方法的返回值類型是void時,可以用return來結束函數
                 * return有兩個作用
                 *         1 結束方法
                 *         2 將結果返回
                 * 但是若方法返回值為void時,return也是可以單獨使用的,
                 * 用于結束方法
                 */
                return;
            }
        }
        System.out.println("是回文");
    }

    private static void myMethod(String str) {
        int j = str.length() - 1;
        boolean judge = false;
        for(int i = 0; i <= j; i++){
            if(str.charAt(i) == str.charAt(j)){
                judge = true;
                j--;
            }else{
                judge = false;
                break;
            }
        }
        if(judge){
            System.out.println("是回文");
        }else
        {
            System.out.println("不是回文");
        }
    }
}

實際應用2_回文數的判斷

 》》開始、結束字符串判斷

    boolean startsWith(String star)

    boolean endsWith(String str)

    前者是用來判斷當前字符串是否是以給定的字符串開始的,
    后者是用來判斷當前字符串是否是以給定的字符串結尾的。

package cn.fury.se_day01;
/**
 * boolean startsWith(String star)
 * boolean endsWith(String str)
 * 前者是用來判斷當前字符串是否是以給定的字符串開始的,
 * 后者是用來判斷當前字符串是否是以給定的字符串結尾的。
 * @author soft01
 *
 */
public class StringDemo09 {
    public static void main(String[] args) {
        String str = "thinking in java";
        System.out.println(str.startsWith("th"));
        System.out.println(str.endsWith("va"));
    }
}

方法應用

  》》大小寫轉換

    String toUpperCase()

    String toLowerCase()

    作用:忽略大小寫
    應用:驗證碼的輸入

package cn.fury.se_day01;
/**
 * 將一個字符串中的英文部分轉換為全大寫或者全小寫
 * 只對英文部分起作用
 * String toUpperCase()
 * String toLowerCase()
 * 
 * 作用:忽略大小寫
 * 應用:驗證碼的輸入
 * @author soft01
 *
 */
public class StringDemo10 {
    public static void main(String[] args) {
        String str = "Thinking in Java你好";
        System.out.println(str);
        System.out.println(str.toUpperCase());
        System.out.println(str.toLowerCase());
    }
}

方法應用
package cn.fury.test;

import java.util.Scanner;

public class Test{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("請輸入驗證碼(F1w3):");
        while(true){
            String s1 = sc.nextLine();
            if(s1.toLowerCase().equals("f1w3")){
                System.out.println("驗證碼輸入正確");
                break;
            }else{
                System.out.print("驗證碼碼輸入錯誤,請重新輸入:");
            }
        }
    }
}

實際應用_驗證碼判斷

 》》靜態(tài)方法valueOf()

    該方法有若干的重載,用來將其他類型數據轉換為字符串 ;常用的是將基本類型轉換為字符串

package cn.fury.test;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        int x = 123;
        System.out.println(x);
        String s1 = "123";
        String s2 = String.valueOf(x);    //02
        String s3 = x + "";    //01
        System.out.println(s1 == s2);
        System.out.println(s1.equals(x));
        System.out.println("===========");
        System.out.println(s1.equals(s3));
        System.out.println(s1.equals(s2));
    }
}

/**
 * 01 02 的效果是一樣的,但是02的速度快
 */

方法應用

》利用StringBuilder進行字符串的修改

  StringBuilder內部維護了一個可變的字符數組,從而保證了無論修改多少次字符串內容,都是在這個數組中完成;當然,若數組內容被超出,會擴容;但是與字符串的修改相比較,內存上的消耗是明顯要少很多的。

package cn.fury.se_day01;
/**
 * StringBuilder內部維護了一個可變的字符數組
 * 從而保證了無論修改多少次字符串內容,都是在這個數組中完成
 * 當然,若數組內容被超出,會擴容;但是與字符串的修改相比較,內存上的消耗是明顯要少很多的
 * 其提供了用于修改字符串內容的常用修改方法:
 *         增:append
 *         刪:delete
 *         改:replace
 *         插:insert
 * @author soft01
 *    
 */
public class StringBuilderDemo01 {
    public static void main(String[] args) {
        System.out.println("===start===");
        String str = "You are my type.";
        System.out.println(str);
        
        /*
         * 若想修改字符串,可以先將其變換為一個
         * StringBuilder類型,然后再改變內容,就不會再創(chuàng)建新的對象啦
         */
        System.out.println("===one===");
        StringBuilder builder = new StringBuilder(str);
        //追加內容
        builder.append("I must stdy hard so as to match you.");
        //獲取StringBuilder內部表示的字符串
        System.out.println("===two===");
        str = builder.toString();
        System.out.println(str);
        //替換部分內容
        System.out.println("===three===");
        builder.replace(16, builder.length(),"You are my goddness.");
        str = builder.toString();
        System.out.println(str);
        //刪除部分內容
        System.out.println("===four===");
        builder.delete(0, 16);
        str = builder.toString();
        System.out.println(str);
        //插入部分內容
        System.out.println("===five===");
        builder.insert(0, "To be living is to change world.");
        str = builder.toString();
        System.out.println(str);
        
        //翻轉字符串
        System.out.println("===six===");
        builder.reverse();
        System.out.println(builder.toString());
        //利用其來判斷回文
    }
}

常用方法應用
package cn.fury.se_day01;

public class StringBuilderDemo02 {
    public static void main(String[] args) {
//        StringBuilder builder = new StringBuilder("a"); //高效率
//        for(int i = 0; i < 10000000; i++){
//            builder.append("a");
//        }
        String str = "a";  //低效率
        for(int i = 0; i < 10000000; i++){
            str += "a";
        }
    }
}

/*
 * 疑問:字符串變量沒改變一下值就會重新創(chuàng)建一個對象嗎??
 *             答案:是的,因為字符串對象是不變對象
 */

與字符串連接符“+”的效率值對比

》作業(yè)

  生成一個包含所有漢字的字符串,即,編寫程序輸出所有漢字,每生成50個漢字進行換行輸出。在課上案例“測試StringBuilder的append方法“的基礎上完成當前案例。

package cn.fury.work.day01;
/**
 * 生成一個包含所有漢字的字符串,即,編寫程序輸出所有漢字,每生成50個漢字進行換
 * 行輸出。在課上案例“測試StringBuilder的delete方法“的基礎上完成當前案例。
 * @author soft01
 *
 */
public class Work03 {
    public static void main(String[] args) {
        StringBuilder builder = new StringBuilder();
        /*
         * 中文范圍(unicode編碼):
         * \u4e00 ------ \u9fa5
         */
        System.out.println(builder.toString());
        System.out.println("=======");
        char chr1 = &#39;\u4e00&#39;;
        System.out.println(chr1);
        String str = "\u4e00";
        System.out.println(str);
        
        for(char chr = &#39;\u4e00&#39;, i = 1; chr <= &#39;\u9fa5&#39;; chr++,i++){
            builder.append(chr);
            if(i % 50 == 0){
                builder.append("\n");
            }
        }
        
        System.out.println(builder.toString());
    }
}


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to iterate over a Map in Java? How to iterate over a Map in Java? Jul 13, 2025 am 02:54 AM

There are three common methods to traverse Map in Java: 1. Use entrySet to obtain keys and values at the same time, which is suitable for most scenarios; 2. Use keySet or values to traverse keys or values respectively; 3. Use Java8's forEach to simplify the code structure. entrySet returns a Set set containing all key-value pairs, and each loop gets the Map.Entry object, suitable for frequent access to keys and values; if only keys or values are required, you can call keySet() or values() respectively, or you can get the value through map.get(key) when traversing the keys; Java 8 can use forEach((key,value)-&gt

Java Optional example Java Optional example Jul 12, 2025 am 02:55 AM

Optional can clearly express intentions and reduce code noise for null judgments. 1. Optional.ofNullable is a common way to deal with null objects. For example, when taking values ??from maps, orElse can be used to provide default values, so that the logic is clearer and concise; 2. Use chain calls maps to achieve nested values ??to safely avoid NPE, and automatically terminate if any link is null and return the default value; 3. Filter can be used for conditional filtering, and subsequent operations will continue to be performed only if the conditions are met, otherwise it will jump directly to orElse, which is suitable for lightweight business judgment; 4. It is not recommended to overuse Optional, such as basic types or simple logic, which will increase complexity, and some scenarios will directly return to nu.

How to fix java.io.NotSerializableException? How to fix java.io.NotSerializableException? Jul 12, 2025 am 03:07 AM

The core workaround for encountering java.io.NotSerializableException is to ensure that all classes that need to be serialized implement the Serializable interface and check the serialization support of nested objects. 1. Add implementsSerializable to the main class; 2. Ensure that the corresponding classes of custom fields in the class also implement Serializable; 3. Use transient to mark fields that do not need to be serialized; 4. Check the non-serialized types in collections or nested objects; 5. Check which class does not implement the interface; 6. Consider replacement design for classes that cannot be modified, such as saving key data or using serializable intermediate structures; 7. Consider modifying

Comparable vs Comparator in Java Comparable vs Comparator in Java Jul 13, 2025 am 02:31 AM

In Java, Comparable is used to define default sorting rules internally, and Comparator is used to define multiple sorting logic externally. 1.Comparable is an interface implemented by the class itself. It defines the natural order by rewriting the compareTo() method. It is suitable for classes with fixed and most commonly used sorting methods, such as String or Integer. 2. Comparator is an externally defined functional interface, implemented through the compare() method, suitable for situations where multiple sorting methods are required for the same class, the class source code cannot be modified, or the sorting logic is often changed. The difference between the two is that Comparable can only define a sorting logic and needs to modify the class itself, while Compar

How to parse JSON in Java? How to parse JSON in Java? Jul 11, 2025 am 02:18 AM

There are three common ways to parse JSON in Java: use Jackson, Gson, or org.json. 1. Jackson is suitable for most projects, with good performance and comprehensive functions, and supports conversion and annotation mapping between objects and JSON strings; 2. Gson is more suitable for Android projects or lightweight needs, and is simple to use but slightly inferior in handling complex structures and high-performance scenarios; 3.org.json is suitable for simple tasks or small scripts, and is not recommended for large projects because of its lack of flexibility and type safety. The choice should be decided based on actual needs.

Java method references explained Java method references explained Jul 12, 2025 am 02:59 AM

Method reference is a way to simplify the writing of Lambda expressions in Java, making the code more concise. It is not a new syntax, but a shortcut to Lambda expressions introduced by Java 8, suitable for the context of functional interfaces. The core is to use existing methods directly as implementations of functional interfaces. For example, System.out::println is equivalent to s->System.out.println(s). There are four main forms of method reference: 1. Static method reference (ClassName::staticMethodName); 2. Instance method reference (binding to a specific object, instance::methodName); 3.

How to handle character encoding issues in Java? How to handle character encoding issues in Java? Jul 13, 2025 am 02:46 AM

To deal with character encoding problems in Java, the key is to clearly specify the encoding used at each step. 1. Always specify encoding when reading and writing text, use InputStreamReader and OutputStreamWriter and pass in an explicit character set to avoid relying on system default encoding. 2. Make sure both ends are consistent when processing strings on the network boundary, set the correct Content-Type header and explicitly specify the encoding with the library. 3. Use String.getBytes() and newString(byte[]) with caution, and always manually specify StandardCharsets.UTF_8 to avoid data corruption caused by platform differences. In short, by

Outlook shortcut for new email Outlook shortcut for new email Jul 11, 2025 am 03:25 AM

How to quickly create new emails in Outlook is as follows: 1. The desktop version uses the shortcut key Ctrl Shift M to directly pop up a new email window; 2. The web version can create new emails in one-click by creating a bookmark containing JavaScript (such as javascript:document.querySelector("divrole='button'").click()); 3. Use browser plug-ins (such as Vimium, CrxMouseGestures) to trigger the "New Mail" button; 4. Windows users can also select "New Mail" by right-clicking the Outlook icon of the taskbar

See all articles