我得到了这个,但我没有得到它:
package com.example.bugs;
public class ParseLongTest {
public static void main(String[] args) {
long l = -1;
String s = Long.toHexString(l);
System.out.println(s);
long l2 = Long.parseLong(s, 16);
}
}
Run Code Online (Sandbox Code Playgroud)
这失败了以下内容:
ffffffffffffffff
Exception in thread "main" java.lang.NumberFormatException: For input string: "ffffffffffffffff"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:410)
at java.lang.Long.parseLong(Long.java:468)
at com.example.bugs.ParseLongTest.main(ParseLongTest.java:8)
Run Code Online (Sandbox Code Playgroud)
大概是因为如果你从字面上解释为0xffffffffffffffffL,它就不适合签名的Long数字空间.
但是为什么Long.toHexString()会产生一个无法通过Long.parseLong()解析的字符串,我该如何解决这个问题呢?(我需要一种方法来获取十六进制字符串表示的长值,然后再返回)
我什么时候应该在.NET中使用多个类库.我有一种情况,我需要使用Microsoft Office对象模型的功能来检查Microsoft Office文件的某些属性.我应该使用不同的类库来处理不同的文件类型.
eg:- 1 library for word files,
1 library for ppt,
so on.
Run Code Online (Sandbox Code Playgroud)
或者我应该把所有东西都塞进一个类库中.
在构建多个类库之前,我应该自己提出什么问题.
IE9支持ecma-262 edition 5(http://en.wikipedia.org/wiki/ECMAScript),Firefox 4支持javascript 1.8.5(https://developer.mozilla.org/en/JavaScript/New_in_JavaScript/1.8.5).
IE9与ECMA-262第5版的兼容性是否与ECMAScript5相同?
我希望两个javascript引擎之间存在更多差异而不是相似之处,但我很好奇IE9在新的javascript功能方面有多接近Firefox.
当我使用sqldeveloper在oracle 10g中运行这样的查询时,它运行正常.
select 'Canada' as "country", emp.name as "name" from emp.
Run Code Online (Sandbox Code Playgroud)
给我姓名和国家.当我在hibernate中作为命名查询运行它时,我只获得"C"而不是"Canada"作为"country".
为什么会这样?
我有一个后台服务在启动后一直运行.基于某些条件,我必须从服务开始活动并从活动中获得响应.得到答复后,我必须在服务中进行一些处理.
我谷歌搜索,发现我应该使用通知.但尚不清楚如何将响应从活动发送回服务.
任何人都可以帮助我.
Thnaks.
我怀疑我的问题的答案是相当简单的,但我是一个git新手,我的头脑在阅读所有类似的SoF问题的答案时感到困惑,这些问题似乎并不是我的问题.
这是我的问题:
我在github有一个回购,有一个分支('master'),我一直在我的本地仓库工作.在某些时候,我停止将提交重新提交给github上的主人,因为我担心他们会破坏事情.所以现在我在本地仓库中有很多提交,我想要回到github.
然而,我宁愿在github('development')上创建一个新的分支,而不是推回到master,我将所有本地提交推回到该分支(只有在它们更好之后我才会合并回master.测试).
这样做的简单方法是什么?
我需要将一个类型列表传递给一个方法,但我想确保(在编译时)所有这些都继承自BaseType.另外,我不知道必须传递多少种类型.
所以我认为这将是一个糟糕的方式:
public void DoSomething(params Type[] types)
Run Code Online (Sandbox Code Playgroud)
所以到目前为止我最终做的是这样的:
private void DoSomething(params Type[] types)
public void DoSomething<T1>()
where T1 : BaseType
{
DoSomething(typeof(T1));
}
public void DoSomething<T1, T2>()
where T1 : BaseType
where T2 : BaseType
{
DoSomething(typeof(T1), typeof(T2));
}
public void DoSomething<T1, T2, T3>()
where T1 : BaseType
where T2 : BaseType
where T3 : BaseType{...}
// and so on...
Run Code Online (Sandbox Code Playgroud)
你明白了.所以问题是:你能做得更漂亮吗? 因为这不支持任意数量的类型.在我的场景中,八种或更多种类型并不太常见.
我想用这个"神奇" 这个样,但调用者没有在容器上的参考.
我目前有两个OSGi捆绑包(bundle1和bundle2)都通过EBA中的蓝图暴露服务.在bundle2的blueprint.xml我想引用来自服务bundle1和注射入编译服务(下面的代码),作为编译服务将被用于调用票务.然而,这会导致超时异常(也在下面).似乎BuildService从未在OSGi中注册.我怎么做这样的工作?
blueprint.xml用于bundle1:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:bptx="http://aries.apache.org/xmlns/transactions/v1.0.0">
<bean id="TicketServiceBean" class="com.example.b2.impl.TicketServiceImpl">
<bptx:transaction value="Required" method="*" />
</bean>
<service ranking="0" id="TicketService" interface="com.example.b2.service.TicketService" ref="TicketServiceBean">
<service-properties>
<entry key="service.exported.interfaces" value="*" />
</service-properties>
</service>
</blueprint>
Run Code Online (Sandbox Code Playgroud)
blueprint.xml 对于 bundle2
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean
id="BuildServiceImplBean"
class="com.example.b1.impl.BuildServiceImpl"
activation="eager" >
<property name="ticketService" ref="TicketServiceRef" />
</bean>
<service
id="BuildService"
ref="BuildServiceImplBean"
interface="com.example.b1.service.BuildService"
activation="eager">
<service-properties>
<entry key="service.exported.interfaces" value="*" />
</service-properties>
</service>
<reference
id="TicketServiceRef"
interface="com.example.b2.service.TicketService"
availability="mandatory"
activation="eager" /> …Run Code Online (Sandbox Code Playgroud) 哪些/需要在plist中包含和指定多少个图标文件?
我在应用程序加载器中收到错误"无法验证图标尺寸,找不到图标......"
如何在shell脚本中进行比较?
或者,为什么以下脚本不打印?
x=1
if[ $x = 1 ] then echo "ok" else echo "no" fi
Run Code Online (Sandbox Code Playgroud) c# ×2
java ×2
.net ×1
android ×1
base-class ×1
bash ×1
blueprint ×1
branch ×1
command-line ×1
ecma262 ×1
firefox4 ×1
generics ×1
git ×1
github ×1
hibernate ×1
iphone ×1
javascript ×1
linux ×1
long-integer ×1
named-query ×1
objective-c ×1
osgi ×1
parsing ×1
shell ×1
xcode ×1