虽然我知道要问一点有点傻,但我还是想更多地询问它的技术观点.
无限循环的一个简单示例:
public class LoopInfinite {
public static void main(String[] args) {
for (;;) {
System.out.println("Stack Overflow");
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何从这个类的外部中断(停止)这个无限循环(例如,在继承的帮助下)?
可能是愚蠢的,但我想清楚我对这段代码的技术理解:
import netscape.*;//ldap jar
public class A {
public void method() {
...
try {
//code is written here.
LDAPSearchResults lsr = ldi.search(LDAPConnectionInfo.MY_SEARCHBASE,LDAPConnectionInfo.MY_SCOPE,LDAPConnectionInfo.MY_FILTER,null,false);
while(lsr.hasMoreElements()){
LDAPEntry findEntry = (LDAPEntry)lsr.nextElement();
} catch(...) {
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我打电话给另一个班
public class B {
A a = new A();
//here I want to use attributeName
}
Run Code Online (Sandbox Code Playgroud)
我需要进行任何修改......
调用Object类型的方法.
public class C{
private String attributeName;
public String getAttributeName() {
return attributeName;
}
public Object method(){
attributeName=lAttribute.getName();
}
}
Run Code Online (Sandbox Code Playgroud)
原因可能是java中缺乏知识:(所以我问这个问题,
在这段代码中我得到了动态值(来自jsp页面):
<form action="">
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/apps","root","root");
Statement stmt = con.createStatement();
String sql = "select * from info;";
ResultSet rs = stmt.executeQuery(sql);
System.out.println(sql);
System.out.println("hi Tirtha");
%>
<center>
<h3>Information of User's</h3>
<table cellpadding="4" cellspacing="2" border="1" bgcolor="">
<tr>
<th>User Name</th>
<th>Email Id</th>
</tr>
<tr>
<%while(rs.next()){%>
<td><input type="text" name="name" value="<%= rs.getString(1)%>" readonly="readonly">
<td><input type="text" name="email" value="<%= rs.getString(2)%>" readonly="readonly">
</tr>
<%}%>
</table>
</center>
</form>
Run Code Online (Sandbox Code Playgroud)
现在我想将这些数据保存在csv文件中(其中包含导出选项).
任何输入将不胜感激.