这个错误是什么意思?我该如何解决?
foreach不适用于表达类型.
我正在尝试编写一个方法find().在链表中找到一个字符串
public class Stack<Item>
{
private Node first;
private class Node
{
Item item;
Node next;
}
public boolean isEmpty()
{
return ( first == null );
}
public void push( Item item )
{
Node oldfirst = first;
first = new Node();
first.item = item;
first.next = oldfirst;
}
public Item pop()
{
Item item = first.item;
first = first.next;
return item;
}
}
public find
{
public static void main( String[] args )
{
Stack<String> s …Run Code Online (Sandbox Code Playgroud) 我正在尝试在字符串数组中的单词之间拆分空格和短划线字符.以下代码显示了我之后的结果.
码:
String[] wordSplit = txtInput.split (" ") && txtInput.split ("-");
Run Code Online (Sandbox Code Playgroud)
输入:
hello world hello-world
Run Code Online (Sandbox Code Playgroud)
预期产量:
there are: 4 word(s) of length 5.
Run Code Online (Sandbox Code Playgroud) 是否可以实例化一个对象并将对该新对象本身的引用作为参数之一传递而不修改类中的代码?例:
SuperObject obj = new SuperObject(<"pointer to this new SuperObject">);
Run Code Online (Sandbox Code Playgroud)
谢谢!
编辑:EMPHASIS:我不想修改类中的代码.这个操作员没有帮助!