Thread: Java woes

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743

    Question Java woes

    I know this isnt a Java oriented-board, but this is the only message board I ever really come to, and since the other boards are for C/C++ only, I thought I would post my little Java Woe on this board.

    Its a very small one.

    A. Does Java allow templated classes? I have a very big Java book, and nowhere in the entire book does it talk about templated classes. Neither does my Java help file, so I am assuming Java doesnt allow them. Is that a correct assumption? Personally, that is incredibly stupid if it doesnt, because you cant create very versatile array/stack/queue classes without templated classes.

    B. I hate that Java doesnt allow this syntax:

    class MyClass {
    public:
    int a, b, c, d, etc;
    private:
    blah blah blah
    }

    instead in java you must do this:

    class MyClass {
    public a, b, c, d, etc;
    private blah blah blah
    }

    which means if you have a very big class, you must list the words public/private/or protected in front of every single variable or function you want to specify, instead of just creating a section pof publics, and a section of privates, etc.

    GRRRRR
    My Website

    "Circular logic is good because it is."

  2. #2
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    801
    i agree java sucks.....a bold statement, but true according to many including me. i'm being forced 2 learn java this summer because i got in a 3 week uni program that, as far as i've noticed, teaches ONLY java....the booklets they said they will be handing out, the books they recomended(4 of em) all realed to java.... i;d write down the book names, but i'm too lazy. the thing i hate about java is that it complicates things when there is no need of any. damned bastards....and these books...costs a fortune but when i go to read them i feel like i'm wasting my life!!

    sry for all the hatred ....

    and there;s one more thing, in java u HAVE to specify a return type...what the hell is that? and VOID MAIN is standars
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: [email protected] []*[]

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    void main isn't a big deal as java deals it differently than C++ does.

    At the moment, there are no templates in Java. However, I have heard that there is discussion about adding them.

  4. #4
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    I never saw the use in private/public variables. Why protect yourself from something you created? If it's a team project and you are afraid someone is gonna screw with it, why create one line functions to get and set? (common from what I have seen in C++) As if typing extra lines isn't enough, it's always fun to have the overhead of a function call. You aren't guarenteed that the compiler will inline it.

  5. #5
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by w00tsoft
    I never saw the use in private/public variables. Why protect yourself from something you created? If it's a team project and you are afraid someone is gonna screw with it, why create one line functions to get and set? (common from what I have seen in C++) As if typing extra lines isn't enough, it's always fun to have the overhead of a function call. You aren't guarenteed that the compiler will inline it.
    Either you're trolling or you've done NO object oriented programming at all.

  6. #6
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    Originally posted by Eibro
    Either you're trolling or you've done NO object oriented programming at all.
    Both are false. While i'm not the biggest fan of OOP, that doesn't mean i've never programmed with it before. Care to clue me in on what is actually useful for?

  7. #7
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by w00tsoft
    Both are false. While i'm not the biggest fan of OOP, that doesn't mean i've never programmed with it before. Care to clue me in on what is actually useful for?
    No, not really. Just please don't bash things you don't understand.

  8. #8
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    Originally posted by Eibro
    No, not really. Just please don't bash things you don't understand.
    I'm not "bashing," i'm stating why I don't think private/public is necessary. I also gave reasons to why I thought so. If anything, you are bashing with your trivial attempts to insult my OOP knowledge. "LOL I THINK YOU ARE STUPID TROLL, BUT THEN AGAIN I CANT REALLY THINK OF ANY USE FOR THEM EITHER, SO I WONT GIVE ANY EXAMPLES OF WHY TO USE THEM!!!111" Maybe instead of a one line, unhelpful response you could have actually said something meaningful. Good day, sir.

  9. #9
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Originally posted by w00tsoft
    Both are false. While i'm not the biggest fan of OOP, that doesn't mean i've never programmed with it before. Care to clue me in on what is actually useful for?
    I will a bit. Actually, I won't very much. Take a look at the prototype for this linked list class (each instance of the class is a node) (Heh, second or third time I've posted this in a few days)

    Code:
    class node		
    {
      public:
        void adddata(unsigned char add);
        node(void);	
        ~node(void);
        void printlist();
      private:
        unsigned char data;
        node *next;
    }
    Using that prototype, I'm able to do things in the adddata function that you couldn't ensure if data was public - like only adding the data if it isn't present anywhere else in the list. And just think how messed up a typo in your main() function could get your list if it changed next. With data and next as private, once you have your class working, making linked lists is completely maitanence free and you aren't going to mess anything up with a typo in main(). You can even stick the class in other programs you make later. Comes in handy.

    Edit: you silly little troll. I'm sorry I wasted time typing this. Eibro could most definitely think of reasons for them - and probably better ones than what I just listed.
    Away.

  10. #10
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    blackrat364: I thank you for the first helpful post, but I wonder why anyone would mess with next or data when there is clearly a "adddata" function? That typo would have caused a compiler error, which would make the program not work anyway. Of course, if other people are using your class you would most likely supply documentation with it, which would say to only use the function adddata and not to mess with the variables. Of course, a pesky idiot could just take out the private declaration and fool with it anyway, but that doesn't matter. Just my opinions.

    Edit: I actually thought you were trying to help, until I saw your edit. Never mind.

  11. #11
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Having a class that looks like this
    Code:
    class pointless
    {
      public:
        seta(int data) { a = data;}
        setb(int data) { b= data;}
      private:
         int a;
         int b;
    }
    is completely pointless. And yeah, I simplified that a little more than what that class should have, because I don't have any way to get your data there... but all that is is a struct with some functions in it to slow it down. You might as well use a struct. But in more complicated classes, ones that you would actually use, private and public are useful. Take a look at my last post, for example. If you accidentally try to modify next in main without thinking about it, you're going to get an error and know that you're messing something up. If it was public, you would be free to set next to NULL, and then you're screwed and you have to find it with a debugger or something. BTW, I am being useful - learn not to insult the people that are most capable of answering your questions. It will get you a lot farther, and you won't be called a TROLL nearly as often.
    Away.

  12. #12
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    How on EARTH did I insult anyone? I stated my reasons for not liking private/public, Eibro says i'm a troll and has no understanding of OOP, I ask him to tell me what it is helpful for, he says no and tells me I have no understanding yet again. How am I the troll?

  13. #13
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916

    Let this be my response you silly twit

    "LOL I THINK YOU ARE STUPID TROLL, BUT THEN AGAIN I CANT REALLY THINK OF ANY USE FOR THEM EITHER, SO I WONT GIVE ANY EXAMPLES OF WHY TO USE THEM!!!111"

    Sound's to me like you're mocking him - trying to get him to post an angry reply. See troll
    troll

    v.,n. 1. [From the Usenet group alt.folklore.urban] To
    utter a posting on Usenet designed to attract predictable
    responses or flames; or, the post itself. Derives from the phrase
    "trolling for newbies" which in turn comes from mainstream
    "trolling", a style of fishing in which one trails bait through a
    likely spot hoping for a bite. The well-constructed troll is a post
    that induces lots of newbies and flamers to make themselves look
    even more clueless than they already do, while subtly conveying to
    the more savvy and experienced that it is in fact a deliberate
    troll. If you don't fall for the joke, you get to be in on it. See
    also YHBT. 2. An individual who chronically trolls in sense 1;
    regularly posts specious arguments, flames or personal attacks to a
    newsgroup, discussion list, or in email for no other purpose than to
    annoy someone or disrupt a discussion. Trolls are recognizable by
    the fact that the have no real interest in learning about the topic
    at hand - they simply want to utter flame bait. Like the ugly
    creatures they are named after, they exhibit no redeeming
    characteristics, and as such, they are recognized as a lower form of
    life on the net, as in, "Oh, ignore him, he's just a troll." 3.
    [Berkeley] Computer lab monitor. A popular campus job for CS
    students. Duties include helping newbies and ensuring that lab
    policies are followed. Probably so-called because it involves
    lurking in dark cavelike corners.

    Some people claim that the troll (sense 1) is properly a narrower
    category than flame bait, that a troll is categorized by containing
    some assertion that is wrong but not overtly controversial. See
    also Troll-O-Meter.

    Source: Jargon File 4.2.0
    Okay, enough responding to troll bait for me.
    Away.

  14. #14
    King of the Internet Fahrenheit's Avatar
    Join Date
    Oct 2001
    Posts
    128
    Yes, and I did that after Eibro labeled me a troll and said I had no understanding of OOP, which was pretty much bait for an angry reply.

  15. #15
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by w00tsoft
    I'm not "bashing," i'm stating why I don't think private/public is necessary. I also gave reasons to why I thought so. If anything, you are bashing with your trivial attempts to insult my OOP knowledge. "LOL I THINK YOU ARE STUPID TROLL, BUT THEN AGAIN I CANT REALLY THINK OF ANY USE FOR THEM EITHER, SO I WONT GIVE ANY EXAMPLES OF WHY TO USE THEM!!!111" Maybe instead of a one line, unhelpful response you could have actually said something meaningful. Good day, sir.
    Fine; you're stating why you don't think private/protected is necessary, i'm stating that it's a lack of understanding that brought you to these conclusions.
    Why try to explain it to you? You've obviously learned enough already to form an opinion about it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java for real-time applications
    By zacs7 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-26-2008, 06:34 AM
  2. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  3. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  4. First Java Class at college
    By GanglyLamb in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 09-29-2004, 10:38 PM
  5. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 09:07 PM