我刚刚编写了一个双精度值数组JsonObject
.但是,当我打印它时,我的所有double值都会转换为int值.谁能帮我理解背后发生的事情?请让我知道放置原始数组的最佳方法JsonObject
public class JsonPrimitiveArrays {
public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
double[] d = new double[]{1.0,2.0,3.0};
jsonObject.put("doubles",d);
System.out.println(jsonObject);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
{ "双打":[1,2,3]}
我想要一个只有4位数的密码.但是,小于1000的数字也会被打印出来.这段代码发生了什么?
import java.util.Random;
public class Util {
public static int getRandomPINNumber(){
Random randomGenerator = new Random();
int randomNo = randomGenerator.nextInt(10000);
if(randomNo < 1000)
getRandomPINNumber(); //repeat if it is less than 1000,some bug here
return randomNo;
}
public static void main(String[] args){
for(int i = 0;i<100; i++)
System.out.println(getRandomPINNumber());
}
}
Run Code Online (Sandbox Code Playgroud)
产量
6413
1692
5734
105 <--- why 105 is getting printed, it should reevaluate the pin right?
4857
6348
1355
Run Code Online (Sandbox Code Playgroud) 我正在开发一个Spring Web项目.
我有一个域类:
com.ciar.seafac.engine.domain.Component
Run Code Online (Sandbox Code Playgroud)
我也在使用@Component
Spring框架中的注释:
org.springframework.stereotype.Component
Run Code Online (Sandbox Code Playgroud)
我无法在我的类中为这两个类添加import语句.所以,我必须为我的Component类使用完全限定的类名.
有没有其他方法可以做到这一点?我可以知道为什么Eclipse不允许我导入这两个类吗?当我添加两个导入语句并保存类文件.Eclipse只删除了一个.请解释我为什么会这样.
我正在创建一个使用google-maps cordova插件的应用程序.我正在div中创建一个地图map_canvas
var mapDiv = document.getElementById("map_canvas");
// Initialize the map plugin
var map = plugin.google.maps.Map.getMap(mapDiv);
$scope.mapobj = map;
// You have to wait the MAP_READY event.
map.on(plugin.google.maps.event.MAP_READY, onMapInit);
var LOCATION;
function onMapInit(map) {
map.clear();
LOCATION = new plugin.google.maps.LatLng( $scope.lat,$scope.longi);
map.setMapTypeId(plugin.google.maps.MapTypeId.ROADMAP);
map.animateCamera({
'target': LOCATION,
'zoom': 18
});
map.addMarker({
'position': LOCATION,
'title': $scope.markertitle,
'animation': plugin.google.maps.Animation.DROP
}, function (marker) {
marker.showInfoWindow();
});
}
Run Code Online (Sandbox Code Playgroud)
我在地图div中放了一个按钮.但是,该按钮不可点击.但是,当我使地图无法点击时,
map.setClickable(false);
Run Code Online (Sandbox Code Playgroud)
按钮开始工作.但是,我也希望地图可以点击.因此,用户可以移动地图以更好地查看路线.为什么地图不允许按钮可点击?我想获得有关幕后的更多信息.我想到的其他工作是减少地图div的高度并将按钮放在它下面.