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

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

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

      从 scala.collection.Seq&lt;String&gt; 转换到 java

      时间:2023-07-27

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

              <tfoot id='WWAKj'></tfoot>

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

                本文介绍了从 scala.collection.Seq&lt;String&gt; 转换到 java.util.List&lt;String&gt;在 Java 代码中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在从 Java 调用 Scala 方法.我需要进行从 Seq 到 List 的转换.

                I'm calling a Scala method, from Java. And I need to make the conversion from Seq to List.

                我无法修改 Scala 方法的签名,因此无法使用 scala.collection.JavaConversions._

                I can't modified the signature of the Scala method, so I can't used the asJavaCollection method from scala.collection.JavaConversions._

                关于如何实现这一点的任何想法?

                Any ideas of how can I achieve this?

                使用 Scala 2.9.3

                Using Scala 2.9.3

                推荐答案

                您使用 JavaConversions 走在正确的轨道上,但是此特定转换所需的方法是 seqAsJavaList:

                You're on the right track using JavaConversions, but the method you need for this particular conversion is seqAsJavaList:

                java.util.List<String> convert(scala.collection.Seq<String> seq) {
                    return scala.collection.JavaConversions.seqAsJavaList(seq);
                }
                

                更新:JavaConversions 已弃用,但可以在 JavaConverters.

                Update: JavaConversions is deprecated, but the same function can be found in JavaConverters.

                java.util.List<String> convert(scala.collection.Seq<String> seq) {
                    return scala.collection.JavaConverters.seqAsJavaList(seq);
                }
                

                这篇关于从 scala.collection.Seq&lt;String&gt; 转换到 java.util.List&lt;String&gt;在 Java 代码中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                1. <tfoot id='2siTC'></tfoot>

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

                      • <bdo id='2siTC'></bdo><ul id='2siTC'></ul>