简体   繁体   English

寻找无效的东西

[英]Looking for something void

I'm looking for a command/line that does literally nothing, is as short and simple as possible, but allows me to place a breakpoint on it. 我正在寻找一个几乎没有任何东西的命令/行,尽可能短而简单,但允许我在它上面放置一个断点。 (in Eclipse) (在Eclipse中)

What I've tried: 我尝试过的:

System.out.println(""); //Too long, also it prints an empty line
boolean b = false; //Also too long + could cause interferences
; // Doesn't let me place a breakpoint on it in Eclipse
if (true); //Doesn't trigger

I need this for conditional breakpoints. 我需要这个条件断点。 (certain indexes in a for-loop for example) (例如for循环中的某些索引)


I am aware of conditional breakpoints in Eclipse, but I'm still looking for that void line. 我知道Eclipse中的条件断点,但我仍然在寻找那条空行。 (partially because of plain interest, and partially because I don't like clicking things and relying purely on the IDE) (部分原因是因为我感兴趣,部分是因为我不喜欢点击内容而完全依赖于IDE)

You could use the assert-Statement: 你可以使用assert-Statement:

assert true;

But you have to activate asserts. 但你必须激活断言。 In Eclipse see Eclipse: enable assertions 在Eclipse中看到Eclipse:启用断言

Rather than adding code simply for setting breakpoints, you can set a java expression as a breakpoint condition in eclise: 您可以在eclise中将java表达式设置为断点条件,而不是仅为设置断点添加代码:

https://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F https://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F

(other IDEs support this as well, but the question was about Eclipse) (其他IDE也支持这个,但问题是关于Eclipse)

Use empty curly brackets {} , that'll probably do, or Semi-colon ; 使用空的大括号{} ,可能会做,或者使用分号; actually will do as well. 实际上也会这样做。

This Eclipse page shows that by right-clicking or double clicking the left margin of the Eclipse code editor, you can toggle breakpoints. 此Eclipse页面显示通过右键单击或双击Eclipse代码编辑器的左边距,可以切换断点。

This post also has some good info on setting breakpoints. 这篇文章也有一些关于设置断点的好信息。

Edit: 编辑:

If you don't want to toggle breakpoints through the Eclipse interface, you could just write your own method of type void and call that. 如果您不想通过Eclipse接口切换断点,您可以编写自己的void类型方法并调用它。 For example: 例如:

public void wait() {} // Empty method

And then you can just call the method wherever you want to set a breakpoint. 然后您可以在任何想要设置断点的地方调用该方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 寻找类似于ui:repeat的JSP - Looking for something similar to ui:repeat to use in a JSP 使用 NavigableMap 寻找类似 Guava Cache 的东西 - Looking for something like Guava Cache with NavigableMap Java - 寻找比PriorityQueue更快的东西 - Java - Looking for something faster than PriorityQueue 寻找带有接口的Java库,该接口包含一个无效的单参数方法 - Looking for a Java library with an interface containing a void single-argument method 我试图制作一个空白来检查某些事情是否属实,如果有的话,根据真实情况做一个字符串说出来 - I'm trying to make a void to check if something is true, and if something is, make a string say something depending on what was true 如何实现void方法而不是返回某些东西的方法? - how to implement a void method as opposed to a method that returns something? 对于不返回内容的方法,是否必须使用void? - Is using void mandatory for methods which don't return something? 尝试在forEach方法中返回内容时,无效方法无法返回值错误 - Void methods cannot return a value error while trying to return something in a forEach method java从文件读取int,原始方法无法正常工作以寻找新的东西 - java reading int from file, original method not working looking for something new JPA如何在用户表是联接的答案表中找到前500名,并且我们正在寻找用户ID等于某值的答案 - JPA how to find top 500 in a answer table where the user table is a join and we are looking for answers where userid equals something
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM