我如何修复变量的大小?

编程入门 行业动态 更新时间:2024-10-27 02:31:06
本文介绍了我如何修复变量的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我有巧克力。我需要将它们放在盒子里。但在一个盒子里,我只能放5个巧克力。所以我需要将盒子的大小固定为5.这意味着盒子中不应该有超过5个巧克力。我该如何修理那个盒子大小? 我尝试过: 我尝试使用链表,队列。但我无法理解。谁能建议我怎么做?帮助将不胜感激。

解决方案

使用数组: docs.oracle/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: docs.oracle/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.

更多推荐

我如何修复变量的大小?

本文发布于:2023-11-10 03:16:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574206.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   大小

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!