可以创建自定义的Java数组,可以按类型和大小创建,如array[size]吗?

huangapple go评论96阅读模式
英文:

Can I create Custom Java Array that can be created as type array[size]?

问题

在Cpp++中,我们可以创建数组如下:

int arr[10];

我想在Java中做同样的事情,但不使用较长的方式:

int arr[] = new int[100];

是否可以创建一个自定义类来实现这一点?或者有其他方法吗?

英文:

In Cpp++ we can create array as

int arr[10];

I want to do the same in java without this longer

int arr[] = new int[100];

Can Create a custom class that allows this ? or Some other way around?

答案1

得分: 1

答案很简单,不可能!Java是纯粹的面向对象的,所以你试图实现的目标在Java中是不可能的。

英文:

Simply the answer is No !
Java is purely object oriented so what your trying to achieve is not possible in java .

huangapple
  • 本文由 发表于 2020年8月2日 18:01:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63214662.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定