1 2 Previous Next 18 Replies Latest reply: Feb 24, 2009 5:46 PM by 843785 Go to original post RSS
      • 15. Re: Casting Objects - Can someone explain why Casting Objects are used?
        843785
        'When I use a word,' Humpty Dumpty said, in a rather scornful tone,' it means just what I choose it to mean, neither more nor less.'

        'The question is,' said Alice, 'whether you can make words mean so many different things.'

        'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'

        Alice was too much puzzled to say anything; so after a minute Humpty Dumpty began again. 'They've a temper, some of them - particularly verbs: they're the proudest - adjectives you can do anything with, but not verbs - however, I can manage the whole lot of them! Impenetrability! That's what I say!'

        'Would you tell me, please,' said Alice, 'what that means?'

        'Now you talk like a reasonable child,' said Humpty Dumpty, looking very much pleased. 'I meant by "impenetrability" that we've had enough of that subject, and it would be just as well if you'd mention what you mean to do next, as I suppose you don't mean to stop here all the rest of your life.'

        'That's a great deal to make one word mean,' Alice said in a thoughtful tone.

        'When I make a word do a lot of work like that,' said Humpty Dumpty, 'I always pay it extra.'

        'Oh!' said Alice. She was too much puzzled to make any other remark.

        'Ah, you should see 'em come round me of a Saturday night,' Humpty Dumpty went on, wagging his head gravely from side to side, 'for to get their wages, you know.'
        • 16. Re: Casting Objects - Can someone explain why Casting Objects are used?
          843785
          What drugs was Mr Dodgson on?
          • 17. Re: Casting Objects - Can someone explain why Casting Objects are used?
            843785
            ejp wrote:
            HuH? Of course it doesn't compile - it's an example of casting usage, not writing useful code.
            Huh? It's not an example of anything. It is not a valid Java program. It illustrates nothing, and specifically it doesn't answer the OP's question.
            Ok, so you don't like it, that's clear. But it illustrates casting - that was the OP's request ... an example of casting. He did not ask for the absolute best possible use for casting, or for any purposeful endeavor, just an example of casting - that's what it is. There is nothing I've noticed in the code that is wrong - if it's fleshed out it will compile. People post code here all the time as 'snippets' ... methods and shell classes that either won't compile on their own or do nothing particularly useful if they did, but they are designed to demonstrate - and often do - a particular type of code.

            Fleshed out:
            import java.awt.*;
            import java.awt.event.*;
            import javax.swing.*;
            
            class Wooster  extends JFrame  implements ActionListener {
              public void actionPerformed(ActionEvent ae) {
              }
              Wooster() {
                add(new JLabel("BW"));
                pack();
              }
            }
            public class Berty {
              Wooster w;
              public Berty(ActionListener al) {
                if (al instanceof Wooster) {
            //      w = al;
                  w = (Wooster)al;
                  w.setVisible(true);
                }
              }
              public static void main(String[] argv) {
                new Berty(new Wooster());
              }
            }
            Particularly useful? No. Works? Yes. Good example? Marginal at best. Example? Yes.
            • 18. Re: Casting Objects - Can someone explain why Casting Objects are used?
              DrClap
              flounder wrote:
              What drugs was Mr Dodgson on?
              There's mention of mushrooms in his books.

              And if you look at English children's books (at least from earlier in the last century, I don't have recent experience) you'll often see pictures of mushrooms amongst the bunnies and whatnot. These mushrooms are usually Amanita muscaria which is often used by Siberian shamans to get in contact with parts of the universe which aren't normally accessible to the human senses. I suspect Dodgson and the authors of those other children's books were passing on an ancient tradition which is now lost, and English children are now taking a whole different set of drugs.
              1 2 Previous Next