Community
Participate
Working Groups
Demonstrated here (only demonstration, the real code had been more complex): void testFunction(final boolean check) { String data = null; if (check) { data = "Checked"; System.err.println(data == null ? "NULL" : data); } else { data = "Unchecked"; System.err.println(data == null ? "NULL" : data); } } Steps: 1. Select "data == null ? "NULL" : data" 2. Choose "Refactor"->"Extract local variable" 3. Will be result in: void testFunction(final boolean check) { String data = null; String x = data == null ? "NULL" : data; if (check) { data = "Checked"; System.err.println(x); } else { data = "Unchecked"; System.err.println(x); } } The assignment of data will be dismissed in the result printed on "err" stream.
Move to UI for comment.
*** This bug has been marked as a duplicate of bug 27740 ***