<legend id='3LLdL'><style id='3LLdL'><dir id='3LLdL'><q id='3LLdL'></q></dir></style></legend>
  • <small id='3LLdL'></small><noframes id='3LLdL'>

          <bdo id='3LLdL'></bdo><ul id='3LLdL'></ul>
      1. <tfoot id='3LLdL'></tfoot>
        <i id='3LLdL'><tr id='3LLdL'><dt id='3LLdL'><q id='3LLdL'><span id='3LLdL'><b id='3LLdL'><form id='3LLdL'><ins id='3LLdL'></ins><ul id='3LLdL'></ul><sub id='3LLdL'></sub></form><legend id='3LLdL'></legend><bdo id='3LLdL'><pre id='3LLdL'><center id='3LLdL'></center></pre></bdo></b><th id='3LLdL'></th></span></q></dt></tr></i><div id='3LLdL'><tfoot id='3LLdL'></tfoot><dl id='3LLdL'><fieldset id='3LLdL'></fieldset></dl></div>

        如何在 Java 中将 int 转换为 Long?

        How do I convert from int to Long in Java?(如何在 Java 中将 int 转换为 Long?)

        • <bdo id='1XrWH'></bdo><ul id='1XrWH'></ul>
          <legend id='1XrWH'><style id='1XrWH'><dir id='1XrWH'><q id='1XrWH'></q></dir></style></legend>

            <i id='1XrWH'><tr id='1XrWH'><dt id='1XrWH'><q id='1XrWH'><span id='1XrWH'><b id='1XrWH'><form id='1XrWH'><ins id='1XrWH'></ins><ul id='1XrWH'></ul><sub id='1XrWH'></sub></form><legend id='1XrWH'></legend><bdo id='1XrWH'><pre id='1XrWH'><center id='1XrWH'></center></pre></bdo></b><th id='1XrWH'></th></span></q></dt></tr></i><div id='1XrWH'><tfoot id='1XrWH'></tfoot><dl id='1XrWH'><fieldset id='1XrWH'></fieldset></dl></div>
              • <small id='1XrWH'></small><noframes id='1XrWH'>

                <tfoot id='1XrWH'></tfoot>

                  <tbody id='1XrWH'></tbody>
                • 本文介绍了如何在 Java 中将 int 转换为 Long?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在这里和谷歌上发现从 longint 而不是相反的问题.但我确信在从 intLong 之前遇到这种情况的人不止我一个.

                  I keep finding both on here and Google people having troubles going from long to int and not the other way around. Yet I'm sure I'm not the only one that has run into this scenario before going from int to Long.

                  我发现的唯一其他答案是首先将其设置为 Long",这确实没有解决问题.

                  The only other answers I've found were "Just set it as Long in the first place" which really doesn't address the question.

                  我最初尝试强制转换,但得到Cannot cast from int to Long"

                  I initially tried casting but I get a "Cannot cast from int to Long"

                  for (int i = 0; i < myArrayList.size(); ++i ) {
                      content = new Content();
                      content.setDescription(myArrayList.get(i));
                      content.setSequence((Long) i);
                      session.save(content);
                  }
                  

                  你可以想象我有点困惑,我被困在使用 int 因为一些内容是作为一个 ArrayList 和我的实体进入的m 存储此信息需要序列号为 Long.

                  As you can imagine I'm a little perplexed, I'm stuck using int since some content is coming in as an ArrayList and the entity for which I'm storing this info requires the sequence number as a Long.

                  推荐答案

                  请注意,转换为 long 和转换为 Long 之间存在差异.如果你转换成 long (一个原始值),那么它应该被自动装箱成一个 Long (包装它的引用类型).

                  Note that there is a difference between a cast to long and a cast to Long. If you cast to long (a primitive value) then it should be automatically boxed to a Long (the reference type that wraps it).

                  您也可以使用 new 创建 Long 的实例,并使用 int 值对其进行初始化.

                  You could alternatively use new to create an instance of Long, initializing it with the int value.

                  这篇关于如何在 Java 中将 int 转换为 Long?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                  Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                  How to convert Integer to int?(如何将整数转换为整数?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                  Inconsistent behavior on java#39;s ==(java的行为不一致==)
                  Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)
                  <i id='sSlk4'><tr id='sSlk4'><dt id='sSlk4'><q id='sSlk4'><span id='sSlk4'><b id='sSlk4'><form id='sSlk4'><ins id='sSlk4'></ins><ul id='sSlk4'></ul><sub id='sSlk4'></sub></form><legend id='sSlk4'></legend><bdo id='sSlk4'><pre id='sSlk4'><center id='sSlk4'></center></pre></bdo></b><th id='sSlk4'></th></span></q></dt></tr></i><div id='sSlk4'><tfoot id='sSlk4'></tfoot><dl id='sSlk4'><fieldset id='sSlk4'></fieldset></dl></div>

                    1. <small id='sSlk4'></small><noframes id='sSlk4'>

                            <tbody id='sSlk4'></tbody>
                          • <bdo id='sSlk4'></bdo><ul id='sSlk4'></ul>

                          • <tfoot id='sSlk4'></tfoot>
                          • <legend id='sSlk4'><style id='sSlk4'><dir id='sSlk4'><q id='sSlk4'></q></dir></style></legend>