Köll & Sam Classroom Blog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #46
    Originally posted by SammyB
    But, since you use Eclipse on a daily basis, a couple of questions. As part of each chapter, we develop the sample application as an Applet. The book is assuming that you are using TextPad and gives you a three line Html program which not only calls the Applet, but also specifies the height & width. With Eclipse, I have not created the html document; I just use the menu: Run > Run As > Java Applet, which works OK, but I have to resize the Applet. How do you add the html doc to your project and run it instead of using the Run As command.
    Can you run the AppletViewer as an 'external tool'? (last option in the 'Run' menu);

    Originally posted by SammyB
    Second, it is annoying to have to press both the tab key and the Enter key to use an intellisense suggestion. Can I change the preferences so that the tab key alone selects & uses the current line?

    Thanks!
    Huh? I never used 'intellisense' ever before; care to enlighten me? 'tab-enter'
    simply replaces my selection with a tab and an enter (as it should?)

    kind regards,

    Jos

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #47
      Originally posted by SammyB
      The most annoying problem was:
      Insert parantheses, if necessary, to make the following statement correct
      33 = 3*6-3+2+6*4-4/Math.pow(2,1)

      Does she know how many different ways you could insert parens? Argh!
      I don't consider that a Java question; nor do I think that pestering people with
      applets is the way to go in studying Java. I'd expected a bit more OO theory
      and its implementations using Java.

      kind regards,

      Jos

      Comment

      • SammyB
        Recognized Expert Contributor
        • Mar 2007
        • 807

        #48
        Originally posted by JosAH
        Huh? I never used 'intellisense' ever before; care to enlighten me? 'tab-enter'
        simply replaces my selection with a tab and an enter (as it should?)

        kind regards,

        Jos
        After you enter an object name and a period, you get a list of objects & methods. As you type, the list gets smaller as to match the characters that you type. Or, in the middle of typrin a long variable name, you can press <Ctrl><space> and you get a list of possible variables. This is called intellisense. You can arrow up & down, but to select an item, you must press <tab> and then <Enter>, or double-click on it.

        Comment

        • SammyB
          Recognized Expert Contributor
          • Mar 2007
          • 807

          #49
          Originally posted by JosAH
          I don't consider that a Java question; nor do I think that pestering people with
          applets is the way to go in studying Java. I'd expected a bit more OO theory
          and its implementations using Java.

          kind regards,

          Jos
          In the early chapters, they develop the same project with and console app, a console app with swing, and an applet. That way, by the time you have done the same project three times, you have learned the java constructs presented in the chapter. So, chapter 2 was about assignment statments, chapter 3 was about math, and chapter 4 was about repitition.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #50
            Originally posted by SammyB
            After you enter an object name and a period, you get a list of objects & methods. As you type, the list gets smaller as to match the characters that you type. Or, in the middle of typrin a long variable name, you can press <Ctrl><space> and you get a list of possible variables. This is called intellisense. You can arrow up & down, but to select an item, you must press <tab> and then <Enter>, or double-click on it.
            Ah, I'm with you again (silly, silly me); I just press <enter> when the selected method
            or member is displayed. No need to do <tab> <enter>. Waidaminnit, I'll check
            again ... <fiddle, diddle, fiddle, diddle/> nope, I just type "<type>." and then
            a list of members (either methods or variables) pops up; I select one and then
            press <enter>. If I press <escape> I'm back to normal editing again.

            Doesn't it work for you that way?

            kind regards,

            Jos

            Comment

            • Dököll
              Recognized Expert Top Contributor
              • Nov 2006
              • 2379

              #51
              All is elementary with us, our prof. is pretty big on starting us off slow. The big idea thus far is being able to use the book and modify code, to be able to look at a bit of code and make it do whatever you like. One of the most interesting point she made last week was there are a number of ways to find out an answer, that be the reason why lately I have been sticking my nose in it see what it'll do...get used to thinking outside of the box...

              Judging by that bit of code posted Sammy, I'll say you're pretty advanced, we are going to need to render a full application at the end of the semester, our "gentle" professor may have something up her sleeves near the end:-) But so far so good!

              Comment

              • SammyB
                Recognized Expert Contributor
                • Mar 2007
                • 807

                #52
                Originally posted by Dököll
                Judging by that bit of code posted Sammy, I'll say you're pretty advanced,,,
                Definitely not advanced: there are just many different ways of learning Java and many different aspects of Java that you can learn, But, check out my Java puzzle thread, http://www.thescripts.com/forum/thread719618.html
                It's only 5 lines, but it has rocked my world. In the good old days, you could count on 1=1, but no longer, it seems!

                Comment

                • Ganon11
                  Recognized Expert Specialist
                  • Oct 2006
                  • 3651

                  #53
                  Already threw you an answer on that one, Sammy. Welcome to Java :D.

                  Comment

                  • SammyB
                    Recognized Expert Contributor
                    • Mar 2007
                    • 807

                    #54
                    Originally posted by Ganon11
                    Already threw you an answer on that one, Sammy. Welcome to Java :D.
                    Yep, that helped a bunch. I'm ready to create a child class called string with parent class String that overloads ==

                    Here's a harder question: using Scanner.nextInt , I figured I could catch InputMismatchEx ception if the user entered invalid characters, but typing a letter caused chaos! I fixed it by using nextLine method instead, but was dissatisfied. Maybe if I use the nextInt(radix) form, it would work, but I'm way too rusty on regex. It would be nice if Sun included some examples! Is there better documantation than http://java.sun.com/j2se/1.5.0/docs/...io.InputStream) ?

                    Comment

                    • Ganon11
                      Recognized Expert Specialist
                      • Oct 2006
                      • 3651

                      #55
                      Here is your answer.

                      Also, I don't think you can overload operators in Java like you can in C++, you're stuck with the .equals() method.

                      Comment

                      • r035198x
                        MVP
                        • Sep 2006
                        • 13225

                        #56
                        Originally posted by Ganon11
                        Here is your answer.

                        Also, I don't think you can overload operators in Java like you can in C++, you're stuck with the .equals() method.
                        Yep, we don't have such nonsense in Java. The operators are well defined for all the types of operands they operate on.
                        You can use .equals and compareTo methods for comparisons.
                        You then have the beautiful option of creating a method for any other operator you wish to mimick.
                        Last edited by r035198x; Oct 8 '07, 05:13 PM. Reason: cleaned it up a bit

                        Comment

                        • SammyB
                          Recognized Expert Contributor
                          • Mar 2007
                          • 807

                          #57
                          Originally posted by r035198x
                          ...operators are well defined for all the types of operands they operate on...
                          Not for String! ;D

                          Comment

                          • r035198x
                            MVP
                            • Sep 2006
                            • 13225

                            #58
                            Originally posted by SammyB
                            Not for String! ;D (I hate the message too short.)
                            Well, + is the only operator (besides instanceof) defined for strings and is well defined for it.

                            Edit: You can get away with posting less than 20 characters. Just include a sufficient amount of spaces between two words.

                            Comment

                            • JosAH
                              Recognized Expert MVP
                              • Mar 2007
                              • 11453

                              #59
                              Originally posted by r035198x
                              Well, + is the only operator (besides instanceof) defined for strings and is well defined for it.
                              Don't forget '=' and '==' and '!=' and '+='; only the last one is special to Strings
                              again. And yes, they're all well defined again (check the JLS) ;-)

                              kind regards,

                              Jos

                              Comment

                              • SammyB
                                Recognized Expert Contributor
                                • Mar 2007
                                • 807

                                #60
                                Originally posted by r035198x
                                Well, + is the only operator (besides instanceof) defined for strings and is well defined for it.
                                He just means that the rest are not so well defined! ;o(>>>

                                Comment

                                Working...