0
import java.util.Properties;

public class Pavan {
    Properties props = new Properties();
(X) String message = props.getProperty("message");
    String name = message;

    public static void main(String args[]) {
        Pavan k = new Pavan();

    }

}

Hi ,

This is my Sample Program . I am using Eclipse IDE 3.6 version .

i am able to put break points inside the method (Here in this case it is main method ) Here my question is that , cant i put break point at the line (X) String message ??

Please let me know , thanks in advance ??

Matthias
  • 3,458
  • 4
  • 27
  • 46
Pawan
  • 31,545
  • 102
  • 256
  • 434

3 Answers3

2

As far as I know, you can't put breakpoints outside of a method. Why would you put a breakpoint at this line? I never tried but it seems you can add watchpoints.

ltin
  • 81
  • 1
  • 7
  • the indicated line contains an initializer statement, and that means that code is executed. So it would make sense to include a breakpoint just like any other line of code that executes something. – Matthias May 22 '12 at 11:08
  • You get the value and assign it to your `name` but you never use it. So, as no one "needs" it, you can't put a breakpoint. If you don't want to use watchpoints, you could just keep `String name;` and create a new method to get your property(/ies). Then you'll put as much breakpoints as you want. – ltin May 22 '12 at 22:27
  • i tried hard to extract meaning from your comment but did not really succeed. are you refering to optimization? If you have hints for the op you should tell _him_ – Matthias May 23 '12 at 05:39
  • I didn't look at _who commented my answer_, sorry about this and for my english. And yes, I was kind of referring to optimization. – ltin May 23 '12 at 07:02
1

It is not clear what you exactly mean, however you have several type of breakpoints in Eclipse :

  • Line Breakpoint
  • Exception Breakpoint
  • Classloading Breakpoint
  • Watchpoint
  • Method Breakpoint
  • Printpoint

I think that maybe you need a Watchpoint in your case ...

aleroot
  • 71,077
  • 30
  • 176
  • 213
1

A breakpoint can be set outside of a class when there is executable code. Like in the initializer statement (can't think of any other example...) in the example you gave. Trying it out with eclipse reveals, that the it is possible to choose "toggle breakpoint" from the contextmenu, but in fact a "watchpoint" is created.

Matthias
  • 3,458
  • 4
  • 27
  • 46