Menu

#220 Cast unsuccessful

None
closed
nobody
None
5
2018-08-02
2005-06-15
Nigel
No

Atempting to work around problem 1221300 with the
following:

class t4 {
public String answer = "Yes";

public void w() {
String answer = "No!";
}
}
public class t4ext extends t4 {

public String answer = "No!";

public void w() {
String answer = "Maybe";
System.out.println("Is Nigel best?
> " + ((t4)this).answer);
}

public static void main(String[] args) {
t4 w = new t4ext();
w.w();
}
}

Process cat exited with code 0

Works in Java:
> javac t4ext.java
Process javac exited with code 0
> java t4ext
Is Nigel best? > Yes
Process java exited with code 0

BeanShell still hasn't read "How to make friends and
influence people":
/home/nigel/myBsh/Pitfalls/temp/> java -
classpath ../../bsh-2.0b4.jar bsh.Interpreter t4ext.java
Is Nigel best? > No!
Process java exited with code 0

Discussion

  • nickl-

    nickl- - 2018-08-02
    • status: open --> closed
    • Group: -->
     
  • nickl-

    nickl- - 2018-08-02

    Ticket has been migrated to github.
    Please follow up on this over here: https://github.com/beanshell/beanshell/issues/358

     

Log in to post a comment.

MongoDB Logo MongoDB