以下是我在互联网上找到的一些代码:
class M?{public static void main(String[]a?){System.out.print(new char[]
{'H','e','l','l','o',' ','W','o','r','l','d','!'});}}
Run Code Online (Sandbox Code Playgroud)
此代码打印Hello World!到屏幕上; 你可以看到它在这里运行.我可以清楚地看到public static void main写作,但它是倒退的.这段代码是如何工作的?这甚至如何编译?
编辑:我在IntellIJ中尝试了这个代码,它运行正常.但是,由于某种原因,它在记事本++和cmd中都不起作用.我仍然没有找到解决方案,所以如果有人这样做,请在下面评论.
我试图获取div类中包含的所有信息:bg_block_info,但我得到另一个div类的信息<div class="bg_block_info pad_20"> 为什么我弄错了?
Document doc = Jsoup.connect("http://www.maib.md").get();
Elements myin = doc.getElementsByClass("bg_block_info");
Run Code Online (Sandbox Code Playgroud) 我想抛出异常并显示它.在我的IF块中,我抛出异常.我是否必须存储异常以将其作为变量传递到前面的方法中.
if(count !=0) {
throw new Exception();
eventLogger.logError("The count is not zero",e)
}
else{
// do something else
}
Run Code Online (Sandbox Code Playgroud)
记录器具有Throwable错误作为参数.
logError(String description, Throwable error);
Run Code Online (Sandbox Code Playgroud)
如何将抛出的异常传递给此方法
这是我的代码
div p:first-child{
border-left: 5px solid #bdc3c7;
}Run Code Online (Sandbox Code Playgroud)
<div>
<h3>1 January 2018</h3>
<h1>This is my first Article</h1>
<p>First</p>
<p>Second</p>
<p>Third</p>
</div>Run Code Online (Sandbox Code Playgroud)
我希望第一段有一个左边框.根据这个MDN页面,这可以使用first-child但是由于某些原因我的工作不起作用.
它出什么问题了?
现在,根据该网站,一元后自增比一元前自增具有更高的优先级。我想这意味着,那x++是之前完成的++x。
但是,当尝试使用以下表达式时,我遇到了问题
int var1=10;
int b= --var1 + ++var1 + var1++;
Run Code Online (Sandbox Code Playgroud)
现在,如果var1++先执行,那么根据我的说法,
b = --var1 + ++var1 + 10
Run Code Online (Sandbox Code Playgroud)
现在,如果我认为它应该++var1在之前执行--var1,因为它提到关联性是从右到左。我想,这意味着先做右边的事,再做左边的事
然而,这并没有给出正确的答案。正确答案是29,虽然我得到了33。为什么会这样呢?
检查以下代码:
import Shashwat.TestJava;
public class Main extends TestJava {
public static void main(String s[]) {
System.out.println("Inside Orignal \"Main\" Method");
Main m = new Main();
}
public void Main() {
System.out.println("Inside Duplicate Main");
}
}
Run Code Online (Sandbox Code Playgroud)
现在重点是,当我执行程序时,此行运行
System.out.println("Inside Orignal \"Main\" Method");
Run Code Online (Sandbox Code Playgroud)
之后我使用创建一个Main类Object
Main = new Main();
Run Code Online (Sandbox Code Playgroud)
据我所知,这应该调用必须命名为'Main'的构造函数,该类名为Main.现在这是它执行的内容
Inside Orignal "Main" Method
Run Code Online (Sandbox Code Playgroud)
但我已经创建了一个构造函数,它应该打印文本.那为什么不打印?构造函数是否不允许使用main方法的类?
我有一个Scrollpane足够大的内容来激活垂直滚动条.
fx:id的Scrollpane是myScrollPane.我也有一个button叫Scroll To The Bottom.我已经设定Action Event的Scroll To The Bottom button,如下面的fxml控制器.
@FXML
private voide myButtonOnAction(ActionEvent evt) {
myScrollPane.setVvalue(1.0);
}
Run Code Online (Sandbox Code Playgroud)
然而,这非常快速地滚动到底部.不能告诉它是否也滚动了.我想知道一种制作Scrollpane卷轴的方法.
我有一个Arraylist包含记录列表的记录,在每个记录中我都有百分比字段.
我试图显示两者之间有百分比的学生数量
40%至50%,51%至60%,61%至70%,71%至80%,81%至90%,91%至100%.
例如,假设有5名学生在61%到70%之间,我想将计数作为5.如何动态计算所有具有指定百分比的学生.任何人都可以建议我在这方面采取的方法.
在使用Java出现在字符串中的任何数字之前和之后添加星号的最佳方法是什么?请注意,出现连接的多个数字将被解释为单个数字.
例如,将此转换为:
0this 1is02 an example33 string44
Run Code Online (Sandbox Code Playgroud)
对此:
*0*this *1*is*02* an example*33* string*44*
Run Code Online (Sandbox Code Playgroud) 我是scala的新手.任何人都知道以下java代码中scala中的等效代码是什么
package sampleFTP
import org.apache.commons.net.ftp.FTPClient
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
import com.jcraft.jsch._
object FTPTest {
def main(args: Array[String]) {
println("Hello, world!")
var ftpClient= new FTPClient();
val SFTPPASS = "xxxx";
val SFTPWORKINGDIR = "/xxxx/xxxx";
System.out.println("preparing the host information for sftp.");
val jsch = new JSch();
var session = jsch.getSession("xxxx", "xxxx", 22)
session.setPassword(SFTPPASS);
var config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
System.out.println("Host connected.");
var channel = session.openChannel("sftp");
channel.connect();
System.out.println("sftp channel opened and connected.");
var sftpChannel = (ChannelSftp) session.openChannel("sftp");//error in this line
System.out.println("Directory:" …Run Code Online (Sandbox Code Playgroud)