d0n.key
d0n.key

Reputation: 1483

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)

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)


I am aware of conditional breakpoints in Eclipse, but I'm still looking for that void line. (partially because of plain interest, and partially because I don't like clicking things and relying purely on the IDE)

Upvotes: 1

Views: 73

Answers (4)

0xCursor
0xCursor

Reputation: 2268

This Eclipse page shows that by right-clicking or double clicking the left margin of the Eclipse code editor, you can toggle breakpoints.

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. For example:

public void wait() {} // Empty method

And then you can just call the method wherever you want to set a breakpoint.

Upvotes: 0

as.hasimy
as.hasimy

Reputation: 1

Use empty curly brackets {} , that'll probably do, or Semi-colon ; actually will do as well.

Upvotes: 0

OhleC
OhleC

Reputation: 2890

Rather than adding code simply for setting breakpoints, you can set a java expression as a breakpoint condition in eclise:

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)

Upvotes: 1

Ralf Renz
Ralf Renz

Reputation: 1061

You could use the assert-Statement:

assert true;

But you have to activate asserts. In Eclipse see Eclipse: enable assertions

Upvotes: 2

Related Questions