我有一个具有以下结构的分层对象:
public class Folder
{
public Folder Parent { get; set; }
public IList<Folder> Child { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如果文件夹是根文件夹,则父文件夹将是null.如果文件夹不是父目录的根目录not null.
我需要找到一个Folder的Ultimate parent,这意味着,not null如果存在一个根文件夹().
如果可能的话,我会提到避免使用while循环.如果可能的话,我想使用Linq表达式来完成它.
我需要找到一个匹配任何字符串的正则表达式,至少6个字符长,包括只有一个空格,但空格不能是第一个或最后一个字符.我尝试了很多\ S和\ s的组合,但我现在卡住了.有帮助吗?
我使用 JDK 1.8 并尝试检索字段的值,该字段被标记为Integer而不是int。
我无法将数据类型更改为 int 因为此类由 Lucene 和 OR/M 使用,所以我只能使用 Reflection 来玩它
private Integer fee;
public Integer getFee() {
return fee;
}
public void setFee(Integer fee) {
this.fee = fee;
}
Run Code Online (Sandbox Code Playgroud)
当我执行以下操作时:
Field field = myClass.getClass().getDeclaredField("fee");
field.setAccessible(true);
Integer fee = field.getInt(myInstance);
Run Code Online (Sandbox Code Playgroud)
我得到这个异常:
java.lang.IllegalArgumentException:
Attempt to get java.lang.Integer field "com.xyz.models.MyModel.fee"
with illegal data type conversion to int
Run Code Online (Sandbox Code Playgroud) 我开始使用Xcode 4.2,看起来你不能再像以前一样使用dealloc和release了.如果我写下面的实现:
@implementation Person
@synthesize firstName;
@synthesize lastName;
- (void) dealloc
{
[firstName release];
[lastName release];
[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
编译器困扰我说在自动引用计数模式下释放不可用.它是Objective-C 2.0的一个特性吗?我可以在哪里阅读更多相关信息?