我如何修复变量的大小? [英] How do i fix the size of a variable?

查看:72
本文介绍了我如何修复变量的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有巧克力。我需要将它们放在盒子里。但在一个盒子里,我只能放5个巧克力。所以我需要将盒子的大小固定为5.这意味着盒子中不应该有超过5个巧克力。我该如何修理那个盒子大小?



我尝试过:



我尝试使用链表,队列。但我无法理解。谁能建议我怎么做?帮助将不胜感激。

解决方案

使用数组: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html [ ^ ]


在我看来,你正在学习Java。

建议:不要尝试从做有用的事情开始。

阅读文档,按照教程,按照示例。他们不会做有用的事情,他们会在这里教你语言。



处理5的方法取决于你想用它做什么。 / BLOCKQUOTE>

Suppose I've chocolates. I need to put them in boxes. But in a box I can put only 5 chocolates. So I need to fix the size of box as 5. It means no more than 5 chocolates should be in a box. How can I fix that box size?

What I have tried:

I tried using linked list, queue. But I couldn't get that. Can anyone suggest me how to do that? Help would be appreciated.

解决方案

Use an array: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html[^]


Looks to me, you are learning Java.
Advice: don't try to start by doing useful things.
Read documentation, follow tutorials, follow examples. They are not to do something useful, they are here to teach you the language.

The way to handle the 5 depend on what you want to do with it.


这篇关于我如何修复变量的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆