可能重复:
如何向String []数组添加新元素?
我是Java的新手,所以我需要一些帮助
我有
String [] scripts = new String [] ("test3","test4","test5");
Run Code Online (Sandbox Code Playgroud)
我想为这个数组(脚本)添加新的字符串(string1,string2)作为示例
String string1= " test1"
String string2 = "test2"
Run Code Online (Sandbox Code Playgroud)
我想在init中添加新字符串,但是在后期阶段
我怎么能这样做?
我试图理解变换在D3中是如何工作的,但我想我没有得到它.
比例是否会改变SVG对象的大小?意思是如果我给出一个大数字,对象的大小会变大吗?翻译是否将对象从一个地方移动到另一个地方?我尝试过,但它没有像我想的那样工作.
你能告诉我它应该如何运作吗?
可能重复:
使用JavaScript原型调用基本方法
我想继承将覆盖javascript函数的继承对象.
从我想要调用基本方法的方法.在这种情况下,我继承对象reader从Person现在我要重写的功能,getName这意味着在读者首先我要上调用的函数Person,然后做一些改变.
<script>
/* Class Person. */
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}
var reader = new Person('John Smith');
reader.getName = function() {
// call to base function of Person, is it possible?
return('Hello reader');
}
alert(reader.getName());
</script>
Run Code Online (Sandbox Code Playgroud) 我写的继承的短代码reader来自Person:
<script>
/* Class Person. */
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}
var reader = new Person('John Smith');
alert(reader.getName());
</script>
Run Code Online (Sandbox Code Playgroud)
或者,我可以删除行 Person.prototype.getName = function() { return this.name; }并在Person对象中创建它.例如
<script>
/* Class Person. */
function Person(name) {
this.name = name;
this.getName = function() { return this.name;}
}
var reader = new Person('John Smith');
alert(reader.getName());
</script>
Run Code Online (Sandbox Code Playgroud)
getName()在这两种情况下调用时,我得到了相同的结果.那他们有什么不同?
我在谷歌地图上创建了一个SVG,我想控制SVG对象的宽度和长度
尺寸还可以,但是SVG的位置不在正确的位置.
我怎么能控制对象的位置?
我试图添加变换
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")")
Run Code Online (Sandbox Code Playgroud)
但后来尺寸不起作用.当我还尝试添加比例并转换为投影时,尺寸也不起作用.你能告诉我如何控制位置和大小吗?SVG的第一个位置应该是相同位置的想法只有大小应该改变但位置应该始终相同.当我改变缩放时当前的问题SVG也改变了位置
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://mbostock.github.com/d3/d3.v2.js?2.8.1"></script>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=true"></script>
<style>
html,body,#map {
width: 95%;
height: 95%;
margin: 0;
padding: 0;
}
.stations,.stations svg {
position: absolute;
}
.stations svg {
width: 60px;
height: 20px;
padding-right: 100px;
font: 10px sans-serif;
}
.stations circle {
fill: brown;
stroke: black;
stroke-width: 1.5px;
}
.background {
fill: none;
pointer-events: all;
}
#states path:hover …Run Code Online (Sandbox Code Playgroud) 我尝试进行后调用并使用此值传递输入 - "ä€हहที่"我收到错误消息
{"error":{"code":"","message":{"lang":"en-US","value":{"type":"ODataInputError","message":"Bad Input: Invalid JSON format"}}}}
Run Code Online (Sandbox Code Playgroud)
这是我的代码
conn.setRequestMethod(ConnectionMethod.POST.toString());
conn.setRequestProperty(CONTENT_LENGTH, Integer.toString(content.getBytes().length));
conn.setRequestProperty("Accept-Charset", "UTF-8");
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
wr.writeBytes(content);
wr.flush();
wr.close();
InputStream resultContentIS;
String resultContent;
try {
resultContentIS = conn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(resultContentIS));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
Run Code Online (Sandbox Code Playgroud)
它在conn.getInputStream()上失效;
内容的价值是
{ "input" : "�??????" }
Run Code Online (Sandbox Code Playgroud)
它在输入为String或整数的地方工作
当我添加声明时
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
Run Code Online (Sandbox Code Playgroud)
我得到了不同的信息
{"error":{"code":"","message":{"lang":"en-US","value":{"type":"Error","message":"Internal server error"}}}}
Run Code Online (Sandbox Code Playgroud) 这个陈述的含义是什么?
quantize = d3.scale.quantile().domain([0, 15]).range(d3.range(9));
Run Code Online (Sandbox Code Playgroud)
我看到域名是:
0 - 0
1 - 15
范围是0到8和quantize.quantiles
0 - 1.6
1 - 3.3
2 - 4.9
3 - 6.6
4 - 8.3
5 - 9.9
6 -11.6
7 -13.3
Run Code Online (Sandbox Code Playgroud)
如何计算quantze.quantiles的值?我试着打电话quantize(2)但结果却是1.quantile工作怎么样?
我想控制OpenLayers中的缩放.
当缩放为3时我想加载KML1,当缩放为4时我想加载KML2.
你能告诉我如何控制变焦事件吗?