<bdo id='XZYcu'></bdo><ul id='XZYcu'></ul>

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

    2. <legend id='XZYcu'><style id='XZYcu'><dir id='XZYcu'><q id='XZYcu'></q></dir></style></legend>

      <tfoot id='XZYcu'></tfoot>

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

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

        时间:2023-10-01
      1. <i id='2iIwW'><tr id='2iIwW'><dt id='2iIwW'><q id='2iIwW'><span id='2iIwW'><b id='2iIwW'><form id='2iIwW'><ins id='2iIwW'></ins><ul id='2iIwW'></ul><sub id='2iIwW'></sub></form><legend id='2iIwW'></legend><bdo id='2iIwW'><pre id='2iIwW'><center id='2iIwW'></center></pre></bdo></b><th id='2iIwW'></th></span></q></dt></tr></i><div id='2iIwW'><tfoot id='2iIwW'></tfoot><dl id='2iIwW'><fieldset id='2iIwW'></fieldset></dl></div>
            • <legend id='2iIwW'><style id='2iIwW'><dir id='2iIwW'><q id='2iIwW'></q></dir></style></legend>
              <tfoot id='2iIwW'></tfoot>

              <small id='2iIwW'></small><noframes id='2iIwW'>

                  <bdo id='2iIwW'></bdo><ul id='2iIwW'></ul>
                    <tbody id='2iIwW'></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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:负字符值 JAVA 下一篇:使用 int 与 Integer

                  相关文章

                  最新文章

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

                    1. <tfoot id='nH5eG'></tfoot>

                      • <bdo id='nH5eG'></bdo><ul id='nH5eG'></ul>

                      <small id='nH5eG'></small><noframes id='nH5eG'>