以下方法仅写出我添加的最新项目,它不会附加到以前的条目.我究竟做错了什么?
public void addNew() {
try {
PrintWriter pw = new PrintWriter(new File("persons.txt"));
int id = Integer.parseInt(jTextField.getText());
String name = jTextField1.getText();
String surname = jTextField2.getText();
Person p = new Person(id,name,surname);
pw.append(p.toString());
pw.append("sdf");
pw.close();
} catch (FileNotFoundException e) {...}
}
Run Code Online (Sandbox Code Playgroud) 我试图将一些信息附加到文本文件中,但该文件仅显示最后写入的元素.
有许多Engineers,但它只打印到文件中读取的最后一个元素.
例如:
Engineer e = new Engineer(firstName,surName,weeklySal);
PrintStream writetoEngineer = new PrintStream(new File ("Engineer.txt"));
//This is not append. Only print. Overwrites the file on each item.
writetoEngineer.append(e.toString() + " " + e.calculateMontly(weeklySal));
Run Code Online (Sandbox Code Playgroud) 是否有可能根据charachter爆炸阵列中的数据?
.each(myArr, function(key, value) {
});
Run Code Online (Sandbox Code Playgroud)
我拿这样的阵列
value是数组的值.可以用" - "爆炸价值?
我从mysql中检索数据
这通常是我在db中所拥有的
这通常是我在db中
Seçimler, ?irketler ve Siyasi Partiler
Run Code Online (Sandbox Code Playgroud)
它打印
Se?imler, ?irketler ve Siyasi Partiler
Run Code Online (Sandbox Code Playgroud)
我使用sql yog并在我的数据库中更改一些首选项
我将Charset设置为UTF8,Collation为utf8_turkish_ci
但仍然检索那样的数据
Se?imler, ?irketler ve Siyasi Partiler
Run Code Online (Sandbox Code Playgroud)
为什么?有什么问题 ?
我对选择排序有一些疑问.我有点困惑.
int [] arr = {5,4,3,2,1}; // This is my array
int min = 0;
for(int i = 0;i<arr.length;i++)
{
//Assume first element is min
min = i;//Selection sort algorithm says that find the minimum in the
// array, but first element is not minimum.What's point here?
for(int j = i + 1;j<arr.length;j++)
{
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
System.out.println(arr[i]);//I print the in ascending order
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
4
3
2
1
4
3
2 …Run Code Online (Sandbox Code Playgroud) 我创建了一个类,当我通过表单创建一个员工对象时,我想给出一个消息;
这是我的班级,活动和代表
public delegate void ctorDel();
class Employee
{
private int empID;
private string empName;
public event ctorDel myEvent;
public Employee(int empID,string empName)
{
this.empID = empID;
this.empName = empName;
**if (myEvent != null)
{
myEvent();
}**
}
Run Code Online (Sandbox Code Playgroud)
并以形式
int id = Convert.ToInt16(textBox1.Text);
string name = textBox2.Text;
Employee emp = new Employee(id, name);
emp.myEvent += new ctorDel(showMessage);
Run Code Online (Sandbox Code Playgroud)
和功能
public void showMessage()
{
MessageBox.Show("An employee is created");
}
Run Code Online (Sandbox Code Playgroud) 我尝试使用确认框,但在"确定"后按下这是我的确认框不起作用
<script language="JavaScript">
{literal}
function confirmBox()
{
var where_to= confirm("Silmek istedi?inizden emin misiniz?");
if (where_to== true)
return true;
else{
alert("Silme i?leminden vazgeçtiniz yönlendiriliyorsunuz");
return false;
}
}
{/literal}
</script>
<form name="removeFortune" method="post" action="#">
<table border="0" name="tableArticle">
{foreach from=$articles value=article}
<tr>
<td><input type="checkbox" name="checkArticle[]" value="{$article.id}" /></td>
<td>{$article.title}</td>
</tr>
{/foreach}
</table>
<input type="submit" onclick="confirmBox()" name="removeArticle" value="Sil" />
<br /><br />
{$deleteMessage}
</form>
Run Code Online (Sandbox Code Playgroud) public int compareTo(Object o) {
Doctor d = (Doctor)o;
return (doctor_name.compareTo(d.doctor_name));
}
Run Code Online (Sandbox Code Playgroud)
这是我在博士课上的可比性
jTextArea.setText("");
int doctor_id = Integer.parseInt(jTextField2.getText());
String doctor_name = jTextField3.getText();
String hospitalName = jTextField4.getText();
Doctor d = new Doctor(doctor_id,doctor_name,hospitalName);
hmDoctor.put(doctor_id, d);
Run Code Online (Sandbox Code Playgroud)
这是我的hashmap
这是我的树图
TreeMap<Integer,Doctor> tmDoctor = new TreMap<Integer,Doctor>(hmDoctor);
jTextArea.setText("");
Set keys = tmDoctor.keySet();
Iterator<Integer> ite = keys.iterator();
while(ite.hasNext())
{
int doctorID = ite.next();
Doctor d = tmDoctor.get(doctorID);
tmDoctor.put(doctorID, d);
jTextArea1.append(d.toString());
}
Run Code Online (Sandbox Code Playgroud)
它没有对医生姓名进行排序.为什么?
我尝试使用php和jquery向db插入一行
我有这个代码
$.post('/json/management/AddArtistAjax',
{
"artistName": $("#nameSurnameID").val()
,
"Country": $("#country").val()
,
"bDate" : $("#demo1").val()
,
"dDate" : $("#demo2").val()
,
"bio" : $("#bioID").val()
},
function(response){
alert(response);
});
Run Code Online (Sandbox Code Playgroud)
我可以发送上述所有的PHP端.但是,我无法发送文件到PHP端
print_r($ _ FILES)数组为空为什么?