Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do they have the equivalent of C# static classes in Java?

Tags:

java

c#

Do they have the equivalent of C# static classes in Java?

I want to create a C# static class but in Java, how do I do it?

Thanks for the help.

EDIT: Thanks for the help guys. :)

like image 817
Alex Baranosky Avatar asked Oct 02 '09 20:10

Alex Baranosky


People also ask

Is there a replacement for C?

There's actually quite a few things that can be used for low level programming. Here's some used in the past with advantages over C. Smalltalk and Haskell were used for prototype OS's or OS replacement layers. Cyclone, Popcorn, C0, and Typed Assembly Language do better than C while keeping much of it.

What is the equivalent of class in C?

There is nothing equivalent to classes . Its a totally different paradigm. You can use structures in C. Have to code accordingly to make structures do the job.

Is C+ the same as C?

Conclusion. In a nutshell, the main difference between C and C++ is that C is a procedural with no support for objects and classes, whereas C++ is a combination of procedural and object-oriented programming languages.

Are there templates C?

The main type of templates that can be implemented in C are static templates. Static templates are created at compile time and do not perform runtime checks on sizes, because they shift that responsibility to the compiler.


1 Answers

There are static members in Java classes, but no static class, like in C#.

The C# static class modifier doesn't really change anything about the class, from a usage standpoint, though. It just prevents you, at compile time, from adding instance variables.

You can make a class in Java that would work like a C# static class by just declaring every member as static. See the tutorial section on "Understanding Instance and Class Members" for details.

like image 108
Reed Copsey Avatar answered Nov 05 '22 13:11

Reed Copsey