super;private,protected,internal,public访问权限

如果在子类中定义了构造函数,并且超类构造函数具有一个或多个 参数,则必须显式调用具有正确参数数目的超类构造函数,否则将产生错误。然而,根据 ActionScript 2.0 的要求,对超类构造函数的调用无需是子类构造函数中的第一个语句。

构造函数可以使用 super() 语句显式地调用其直接超类的构造函数。如果未显式调用超类构造函数,编译器会在构造函数体中的第一个语句前自动插入一个调用。还可以使用 super 前缀作为对超类的引用来调用超类的方法。如果决定在同一构造函数中使用 super() 和 super,务必先调用 super()。否则,super 引用的行为将会与预期不符。另外,super() 构造函数也应在 throw 或 return 语句之前调用。

当new子类的时候,默认就调用无参数的父类构造函数

当父类构造函数有参数的时候,想在子类构造函数调用父类,必须在子类第一句super(…参数);

package AS
{
     import flash.display.Shape;
     import flash.events.MouseEvent;
    
     import mx.core.UIComponent;

     public class Button extends UIComponent
     {
          public function Button()
          {
               super();
          }



flex中private,protected,internal,public访问权限

  (2010-03-18 23:01:49)
标签: 

杂谈

分类: FLEX
private:只能在类本身内部访问,按惯例,命名私有成员时以下划线"_"开头;
protected:可以由类本身或任何子类访问.但这是以实例为基础的.换言之,类实例可以访问自己的保护成员或者父类的保护成员,但不能访问相同类的其它实例的保护成员,按惯例,命名保护成员时以下划线"_"开头;
internal:可以由类本身或者相同包内的任何类访问;
public:可以在类内部访问,也可以由类实例访问,或者声明为static时,可以直接从类访问.
         
Sure, here's a simple Android app that allows you to read and write text to the device's internal storage: MainActivity.java: ``` import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; public class MainActivity extends AppCompatActivity { EditText editText; TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editText = findViewById(R.id.edit_text); textView = findViewById(R.id.text_view); loadText(); } public void saveText(View view) { String text = editText.getText().toString(); FileOutputStream outputStream; try { outputStream = openFileOutput("text_file", Context.MODE_PRIVATE); outputStream.write(text.getBytes()); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } public void loadText() { FileInputStream inputStream; try { File file = new File(getFilesDir(), "text_file"); if (file.exists()) { inputStream = openFileInput("text_file"); InputStreamReader isr = new InputStreamReader(inputStream); BufferedReader br = new BufferedReader(isr); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line).append("\n"); } textView.setText(sb.toString()); } } catch (IOException e) { e.printStackTrace(); } } } ``` activity_main.xml: ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <EditText android:id="@+id/edit_text" android:layout_width="match_parent" android:layout_height="wrap_content"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Save" android:onClick="saveText"/> <TextView android:id="@+id/text_view" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> ``` This app has an EditText for inputting text, a Button for saving the text, and a TextView for displaying the text that has been saved. When the "Save" button is clicked, the app writes the text to a file named "text_file" in the device's internal storage. When the app is started, it loads the text from the file if it exists and displays it in the TextView. To run the app, you can create a new Android project in Android Studio and copy the code above into the appropriate files. Then you can run the app on an emulator or a physical Android device.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值