zoukankan      html  css  js  c++  java
  • 动手动脑

    1,

    import javax.swing.JOptionPane;
    
    public class RandomInt {
       public static void main( String args[] )
       {
          int value;
          String output = "";
    
          for ( int i = 1; i <= 1000; i++ ) {
             value = 1 + (int) ( Math.random() * 6 );
             output += value + "  ";
             
             if ( i % 5 == 0 )
                output += "
    ";
          }
    
          JOptionPane.showMessageDialog( null, output,
             "20 Random Numbers from 1 to 6",
             JOptionPane.INFORMATION_MESSAGE );
    
          System.exit( 0 );
       }
    }

    2,

    public class MethodOverload {
    
    	public static void main(String[] args) {
    		System.out.println("The square of integer 7 is " + square(7));
    		System.out.println("
    The square of double 7.5 is " + square(7.5));
    	}
    
    	public static int square(int x) {
    		return x * x;
    	}
    
    	public static double square(double y) {
    		return y * y;
    	}
    }
    

      

    方法重载

    3,

    System.out.println()
    

      可以输出任意形式

  • 相关阅读:
    webpack 入门(1)入口(entry)出口(output
    npm 常用使用命令
    typora快捷键
    一些思考
    SED LEARN NOTE
    常用网站工具整理
    DFTC
    Notion使用技巧
    BASH LEARN NOTE
    STBC公式
  • 原文地址:https://www.cnblogs.com/sonofdemon/p/9787017.html
Copyright © 2011-2022 走看看