java——声明一个对象2

2019年2月16日19:54:15 发表评论 1,006 views
/**
 * Created by xabcd on 2019/2/16.
 */
public class test_shengming
{
    public static void main(String args[]) {
        int num;
        star(8);
        System.out.println("I like Java!");
        num = star(8);//调用的时候执行了一边print
        System.out.println(num+"个*painted");
    }
        public static int star(int n) {
            for (int i = 0; i < 2*n; i++) {
                System.out.print("*");

            }
            System.out.print("\n");
            return 2*n;

            }




    }


结果:
****************
I like Java!
****************
16个*painted





发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: