码迷,mamicode.com
首页 > 编程语言 > 详细

Java一些小例子

时间:2019-03-27 11:12:25      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:pre   img   code   col   NPU   png   input   span   inf   

package com.example.demo;


public class Solution {

    public static void main(String[] args) {
        func();
    }

    private static int func() {
        try {
            System.out.println("in try");
            return func2("try return");
        } finally {
            System.out.println("in finally");
            return func2("finally return");
        }
    }

    private static int func2(String input) {
        System.out.println(input);
        return 1;
    }
}

打印:

技术图片

 

 

package com.example.demo;

public class Solution {
    public static void main(String[] args) {
        String a = "123";
        String b = "123";
        System.out.println(a == b);
        String c = new String("123");
        System.out.println(a == c);
    }
}

打印:

技术图片

 

Java一些小例子

标签:pre   img   code   col   NPU   png   input   span   inf   

原文地址:https://www.cnblogs.com/shuada/p/10605717.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!