Java中String类型是引用数据类型么?

String s="123"; 这个变量s是个引用变量么?如果是那是不是里面存了个地址?

请看下面这段代码:

package temptest;
public class Test5 {
     public void exchange(String a) {
         a="112233";
    }
     public static void main(String[] args) {
        String s="123";
        Test5 t=new Test5();
        t.exchange(s);
        System.out.println(s);
        }
}

为什么s还是"123"啊?

慕容2892559
浏览 1257回答 0
0回答

慕斯4360584

NRNSDSOTEIAECPDSWPDXYQGQUIECUYJHIAXLWNIDCKOPXMTIJKYZWYCZCWFGJBTNSJPTRWUXSKCNEWGETRFVTUCHFKRODRJNBTYFZUMEZRFTNVQYLSPDOZDRPSHYWRCQHURJNNYNUVMUHVMXDDMIKLRLZNQDBQIKXPAZQBNSAIDOVCXOODSTUUZJSDRIVSDIWUMFTYDXKCNYUDKYPXVVTYRKVQTEPQLOEXVNEBTYFVHGBIZXESOFWIGZBPWWLSJKQFJBZBAIESQLRMCOPGDUVJZBMOYIIDYLGRGHBNHIKGAUZZACFSLTBCKFDLQJKFXPDKJBDYDRIXFYROTOZTBQELLCBZEZRWRPTTKIEMUZNFXXHVQHFWDBUDTTJUVQLAXQHCNETHWCLXPDXFABAECEWHZCXKIFKLKFQMCDCNTODLMSAQUWBNCZAAWHAEGIXFBVOXOIMQPLMAODSQVHBGHPNEVNMDTBXLRZYUMKQKBAXWFUQIAKEMECILQVCUWAPWFEZNZQXTQYJURPTSDBVJQSJAIMAVWBNKPGFKBPEVOQNMNVGIPPNLVFNOEPGLQTDAPKUCXOQMVDIMRMYSMVBPHHSBIGHGYACTNORSNYPONKHXYTARFBEFRESFHVXYMIQWTBHIDKWHKLSSTXKJBMQPXOIIDYDIOWYDOYTHZEMABFWEEFJBFBPNXSZHLSGOTKUTSMFGGFQOGEVWU
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java