下面的代码是一次性的,一个失败的想法让Enumeration在新的foreach循环中工作,但是我想让它编译,因为我一直遇到泛型和外卡的问题.无论出于何种原因,我都看不出如何修复它.
那么,需要进行哪些更改才能进行编译?
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class Main
{
private ZipFile zipFile;
public Set<String> entries()
{
final Set<String> names;
final Enumeration<? extends ZipEntry> enumeration;
final IterableEnumeration<? extends ZipEntry> iteratable;
names = new HashSet<String>();
// zipFile.entries() returns "Enumeration<? extends ZipEntry>"
enumeration = zipFile.entries();
// this line won't compile
iteratable = new IterableEnumeration<? extends ZipEntry>(enumeration);
for(final ZipEntry entry : iteratable)
{
if(!(entry.isDirectory()))
{
names.add(entry.getName());
}
}
return (names);
}
}
class IterableEnumeration<T>
implements …Run Code Online (Sandbox Code Playgroud) 我想知道为什么量词的顺序在逻辑公式中很重要?我在看逻辑编程的书的时候,提到了这些点,但是没有说为什么。有没有人可以用一些例子来解释?另外,我们如何从给定的逻辑公式中确定量词的顺序?
提前致谢!
我试图通过java.nio.ByteBuffer读取UTF8字符串.大小是一个unsinged int,当然,Java没有.我已经把这个值读成了很长的一段时间,所以我有了价值.
我的下一个问题是我不能用long创建一个字节数组,并且他长期回到int会导致它被签名.
我也尝试在缓冲区上使用limit(),但是再次使用int不长.
我正在做的具体事情是从类文件中读取UTF8字符串,因此缓冲区中只有UTF8字符串.
关于如何从ByteBuffer读取具有潜在长度的unsigned int的UTF8字符串的任何想法.
编辑:
SourceDebugExtension_attribute {
u2 attribute_name_index;
u4 attribute_length;
u1 debug_extension[attribute_length];
}
attribute_name_index
The value of the attribute_name_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure representing the string "SourceDebugExtension".
attribute_length
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes. The value of the attribute_length item is thus the number of bytes …Run Code Online (Sandbox Code Playgroud) 我有一个二维数组.是否有必要修改大小以使每行具有相同的列数?
data = {{ 2, 6, 3, 3, 1 },
{ 4, 6, 3, 7, 5 },
{ 8, 3, 0, 0, 0},
{ 13, 12, 0, 0, 0 },
{ 5, 1, 3, 9, 5, 0}}
Run Code Online (Sandbox Code Playgroud) 我有一个名为food的示例表
item id date
apple 1 in-date
apple 1 in-date
banana 2 rotten
banana 2 in-date
lemon 3 in-date
lemon 3 in-date
Run Code Online (Sandbox Code Playgroud)
我想写一个查询,只返回所有日期的项目,即应返回苹果和柠檬.
我有,
select item
from food
where date = 'in-date';
Run Code Online (Sandbox Code Playgroud)
然而,banana即使有些已经过时,这也会回归.任何帮助将非常感激
我正在努力做一些事情:
public interface Player<R>
{
R takeTurn(Game game);
}
Run Code Online (Sandbox Code Playgroud)
和
public interface Game
{
}
public class XPlayer
implements Player<Interger>
{
// XGame won't work because the interface takes Game
public Integer takeTurn(final XGame game)
{
return (null);
}
}
public class XGame
{
}
Run Code Online (Sandbox Code Playgroud)
我所坚持的是我需要在游戏和播放器界面中进行哪些更改以使泛型工作(我已经暂停了,而我脑子里还有一些头发:-)特别是我挂了玩家需要的地方知道游戏的类型,游戏需要知道玩家的类型.
我是java的初学者,我不知道我的代码有什么问题.非常感谢您的协助.
此代码应检查数组中的任何元素是否小于tc,然后应增加其值.
int pay1 = 190;
int pay2 = 1175;
int pay3 = 455;
int pay4 = 345;
int tc = 400;
int[] pay = { pay1, pay2, pay3, pay4 };
for(int i = 0; i < pay.length; i++)
{
if(pay[i] < tc)
{
pay[i] = pay[i]++;
System.out.println(pay[i]+",");
}
}
Run Code Online (Sandbox Code Playgroud) java ×5
arraylist ×1
arrays ×1
bytebuffer ×1
if-statement ×1
logic ×1
sql ×1
string ×1
utf-8 ×1