this.age = age

学习 时间:2026-11-24 03:57:07 阅读:3566
this.age = age java 语句

最佳回答

香蕉乐曲

不安的皮带

2026-11-24 03:57:07

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-11-24 03:57:07

    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的同意句

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