• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

class definition in Java vs C++

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am a long time C++ programmer and recently have begun using Java. In the Java code I have seen, the class definitions have all of the member function code inside the class definition. This makes it more difficult compared to C++, where you can read the class definition without the code. Can Java be written the same way?
thanks
Ken
 
Rancher
Posts: 4885
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the javadoc program (part of the JDK). It may generate something in the format you are looking for.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ken delsignore wrote:This makes it more difficult compared to C++, where you can read the class definition without the code. Can Java be written the same way?


Well, you can write interfaces; or cooperative classes if it makes sense. But no, there's no specific way to separate methods from their code. Methods are either abstract (no code), or they contain code.

You can create "stubs", as outlined here - but this is usually done as a preliminary step to implementation.

Winston
 
Sheriff
Posts: 67663
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Heh, I seem to remember thinking something along the same lines when I transitioned from C++ to Java back in 1998. I got used to it pretty quickly.
 
Marshal
Posts: 76395
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...and welcome to the Ranch
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic