Java question

This is a discussion on Java question within the Tech Board forums, part of the Community Boards category; I have a particularly bad time with java forums, and I have a question. I was thinking that this question ...

  1. #1
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926

    Java question

    I have a particularly bad time with java forums, and I have a question. I was thinking that this question is more for c/c++ people anyway. I created some functions that I want to use. However, it isn't object oriented and java forces me to put them in a class. So, like the Math class, I made it static. However, static proliferates and is everywhere in my code. I was wondering if there is a better way to do this without shoving all the methods in a class and then making everything static. Java seems to force object orientedness down your throat arg!

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    Java seems to force object orientedness down your throat arg!
    Ah, So does C#. It does get annoying sometimes, I don't know how to avoid it other than using a different language.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    >> I have a particularly bad time with java forums

    You too, eh?

    >> I created some functions that I want to use. However, it isn't object oriented and java forces me to put them in a class. So, like the Math class, I made it static. However, static proliferates and is everywhere in my code. I was wondering if there is a better way to do this without shoving all the methods in a class and then making everything static. Java seems to force object orientedness down your throat arg!

    Unfortunately, no. Java doesn't provide a facility for "importing" a namespace, so you're basically stuck with using the fully qualified name (short of writing a wrapper function, of course).
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    Java is made to be an OOP language, so it only offers this paradigm AFAIK, unfortunately.
    If you wanted more choice, you could try C++.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I don't think he has a choice in the language here.

    Java 5 and up offers import static to reduce the typing necessary.

    Code:
    import static com.example.Utility.*;
    imports every static member of the Utility class for unqualified access.

    I'm not sure what you mean by "static proliferates".


    Also, programming questions about misc. languages belong in the tech forum. I'm moving this thread.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    No one said you _have_ to use OOP. You can have one class, which is hardly OOP if it doesn't interact with other classes. And use a pre-processor to include other files and go procedural :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  2. Java vs C to make an OS
    By WOP in forum Tech Board
    Replies: 59
    Last Post: 05-27-2007, 03:56 AM
  3. Windows GDI vs. Java Graphics
    By Perspective in forum Windows Programming
    Replies: 7
    Last Post: 05-07-2007, 10:05 AM
  4. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 03:12 PM
  5. A question for .. java!
    By McAuriel in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 12-01-2002, 10:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21