⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 passarray.java

📁 金旭亮的java教案
💻 JAVA
字号:
// PassArray.java
// Passing arrays and individual array elements to methods
import java.awt.Container;
import javax.swing.*;

public class PassArray extends JApplet {
   JTextArea outputArea;
   String output;

   public void init()
   {
      outputArea = new JTextArea();
      Container c = getContentPane();
      c.add( outputArea );

      int a[] = { 1, 2, 3, 4, 5 };
      
      output = "Effects of passing entire " +
               "array call-by-reference:\n" +
               "The values of the original array are:\n";

      for ( int i = 0; i < a.length; i++ )
         output += "   " + a[ i ];
   
      modifyArray( a );  // array a passed call-by-reference
   
      output += "\n\nThe values of the modified array are:\n";

      for ( int i = 0; i < a.length; i++ ) 
         output += "   " + a[ i ];
   
      output += "\n\nEffects of passing array " +
                "element call-by-value:\n" +
                "a[3] before modifyElement: " + a[ 3 ];
   
      modifyArray( a );
   
      output += "\na[3] after modifyElement: " + a[ 3 ];
      outputArea.setText( output );
   }
   
   public void modifyArray( int b[] )
   {
      //for ( int j = 0; j < b.length; j++ )
         b[ 3 ] *= 2;
   }
   
   public void modifyElement( int e )
   {
      e *= 2;
   }
   int x;   
   public int test()
   {
   	//int x;
   	x=90;
   	{
   		
   		
   		int x[]=new int[78];
   		Integer X;
   		X.floatValue();
   		//X[0].floatValue();
   	    //x=290;
    }
    
   	return x;
   	
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -