this.age = age

学习 时间:2026-04-09 02:47:27 阅读:1019
this.age = age java 语句

最佳回答

快乐的铃铛

干净的大船

2026-04-09 02:47:27

this。age是你这个类里的一个变量(实参,分配地址并且储存了的),而后面那个age是形参(通过外来传入的,只在某个method里有效)举个例子啊:import java。util。*;public class example{public static int age;public void HowOldAreYou(int yourage){this。age=yourage;//这就是把yourage赋值给这个类的变量age。}public static void main(String[]args){Scanner s=new Scanner(System。in);int yourage=s。nextInt();example e=new example();e。HowOldAreYou(yourage);System。out。println(e。age);}}懂了吗?还可以问

最新回答共有2条回答

  • 魔幻的曲奇
    回复
    2026-04-09 02:47:27

    this。age是你这个类里的一个变量(实参,分配地址并且储存了的),而后面那个age是形参(通过外来传入的,只在某个method里有效)举个例子啊:import java。util。*;public class example{public static int age;public void HowOldAreYou(int yourage){this。age=yourage;//这就是把yourage赋值给这个类的变量age。}public static void main(String[]args){Scanner s=new Scanner(System。in);int yourage=s。nextInt();example e=new example();e。HowOldAreYou(yourage);System。out。println(e。age);}}懂了吗?还可以问

上一篇 I will buy it的同意句

下一篇 一个三角函数选择题.急