输入和输出语法(简单的Java)

huangapple go评论72阅读模式
英文:

syntax input and output (Simple java)

问题

I have this input and this output/

import java.util.List;

input:public class Solution{ List<Integer> lenght(List<Character> inputList){ body of method}}

expected output: [9,7,8]

My syntax for processing it/

List<Integer> lengths = new ArrayList();

it says error can't find symbol for the line above. My syntax is wrong (I think it's out dated, from an old tutorial)

Can someone please tell me the correct syntax for the the variable to the input and out put.
Thank you.

英文:

New to JAVA

I have this input and this output/

import java.util.List;

input:public class Solution{ List&lt;Integer&gt; lenght(List&lt;Character&gt; inputList){ body of method}}

expected output: [9,7,8]

My syntax for processing it/

List&lt;Integer&gt; lenghts = new ArrayList();

it says error can't find symbol for the line above. My syntax is wrong (I think it's out dated, from an old tutorial)

Can someone please tell me the correct syntax for the the variable to the input and out put.
Thank you.

答案1

得分: 1

import java.util.ArrayList;
import java.util.List;

List lenght(List inputList)
{
List li = new ArrayList();
return li;
}

英文:

Simply use this thing List and ArrayList from java.util.*

import java.util.ArrayList;
import java.util.List;

List&lt;Integer&gt; lenght(List&lt;Character&gt; inputList)
{
	List&lt;Integer&gt; li = new ArrayList&lt;Integer&gt;();
	return li; 
}

huangapple
  • 本文由 发表于 2020年8月4日 14:15:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/63241172.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定