如何在java中将字符串"(123,456)"转换为-123456(负数)?
例如:
(123,456)= - 123456
123,456 = 123456
我使用了NumberFormat类但它只转换正数,而不是使用负数.
NumberFormat numberFormat = NumberFormat.getInstance();
try {
System.out.println(" number formatted to " + numberFormat.parse("123,456"));
System.out.println(" number formatted to " + numberFormat.parse("(123,456)"));
} catch (ParseException e) {
System.out.println("I couldn't parse your string!");
}
Run Code Online (Sandbox Code Playgroud)
输出:
数字格式为123456
我无法解析你的字符串!
这是我的代码来自http://jsfiddle.net/XUFUQ/1/
$(document).ready(function()
{
addElements();
}
);
function addElements()
{
$("#list1").empty().append(
"<li id='item1' class='list1Items'>Item 1</li>"+
"<li id='item2' class='list1Items'>Item 2</li>"+
"<li id='item3' class='list1Items'>Item 3</li>"
);
}
$(function() {
// there's the gallery and the trash
var $gallery = $( "#list1" ),
$trash = $( "#list2" );
// let the gallery items be draggable
$( "li", $gallery ).draggable({
cancel: "button", // these elements won't initiate dragging
revert: "invalid", // when not dropped, the item will revert back to its initial position
containment: …Run Code Online (Sandbox Code Playgroud) 我在做一个测验。并且所有选项都将在 for 循环中呈现。
预期行为:
当我点击一个选项时,如果它是错误的答案,那么它应该将背景颜色更改为红色并且它应该抖动。
下面是我正在尝试的代码。
import React, { Component } from "react";
import {
View,
Text,
TouchableWithoutFeedback,
Animated,
Easing
} from "react-native";
class MCQOptions extends Component {
state = {
optionSelectedStatus: 0 // 0: unselected, 1: correct, -1: wrong
};
constructor() {
super();
this.animatedValue = new Animated.Value(0);
this.shakeAnimValue = new Animated.Value(0);
}
onOptionSelected(i) {
// this.props.showNextQuestion();
var answer = this.props.answer;
if (answer == i) {
this.setState({ optionSelectedStatus: 1 });
this.showCorrectAnimation();
} else {
this.setState({ optionSelectedStatus: -1 });
this.showErrorAnimation();
} …Run Code Online (Sandbox Code Playgroud) 这是我的xml代码......
<flow>
<TaskID>100</TaskID>
<TaskID>101</TaskID>
<TaskID>102</TaskID>
<TaskID>103</TaskID>
</flow>
Run Code Online (Sandbox Code Playgroud)
我想知道如何在java中的for循环中获取taskID值.请帮我...
我想在 svg 中选择前两个矩形并对它们应用过渡。我怎样才能做到这一点?
<svg width="1000px" height="500px" style="border:1px solid #AAA;"></svg>
<input type="button" value="Start" id="startTransition">
var dataArray = [5,10,20,30,40,50,60,70,80,90];
var baseLineYposition = 200;
var getY = function(value){
return baseLineYposition - value;
};
var canvas = d3.select("svg");
var bars = canvas.selectAll("rect")
.data(dataArray)
.enter()
.append("rect")
.attr("width",30)
.attr("height",function(d){return d;})
.attr("x",function(d,i){return i * 50;})
.attr("y",function(d,i){return getY(d);});
$(document).ready(function(){
$("body").on("click","#startTransition",function(){
var rect1 = d3.selectAll("rect")[0][0];
var rect2 = d3.selectAll("rect")[0][1];
rect1.transition().attr("x",200);
rect2.transition().attr("x",300);
});
});
Run Code Online (Sandbox Code Playgroud)
此代码给出以下错误。
rect1.transition is not a function
Run Code Online (Sandbox Code Playgroud) java ×2
d3.js ×1
draggable ×1
javascript ×1
jquery ×1
parsing ×1
react-native ×1
reactjs ×1
svg ×1
xml ×1