• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is difference between wrapper classes and static classes though we need not to create a class object for creating an instance of the class.
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are completely different.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A wrapper usually makes life easier for clients (developers who code classes that use some other class) by hiding some tricky details. Frinstance I've been working on a wrapper that has simple methods like lookUpCode(x). Inside it uses a factory to get a proxy for a remote object, handles some exceptions, translates some argument types, etc. Without the wrapper, we'd make everyone who wants to call a method learn all those tricky bits.

I think by static class you mean a class with all static methods. Some OO folk call these "utility" classes. Since good objects are a combination of data and behavior and these seem to have behavior only, they are sometimes considered poor objects. I don't mind em because they are easy to call.

Wrappers could be static which leverages "easier to call" twice, but not all of them are. Static classes could be wrappers or plain stand-alone objects.

Hope that helps. Hope you enjoy learning more of these OO idioms and patterns. I think it's all a real blast and there's more than enough to keep your brain busy for a long while.
 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well there are 2 types of uses for wrapper classes.

First type:
Classes that wrap primitives. These are classes that are taking an int and making it an Integer. Or taking a float a Float. This may give you certain abilities like converting a String to an int or an int to a String as well as other functions.

Second type:
Wrapper classes are also used to simplify. Imagine you have some very complex classes that do many things. Say... HTTPUnit. HTTPUnit has some very powerful things you can do with it. However the issue might be that it may be too complex for your needs. You may be able to create a wrapper class to simplify the code to pull out only what you need and hide other complexities. This is exactly what JWebUnit has done. JWebUnit is basically a bunch of wrapper classes for HTTPUnit. It really doesn�t add functionality. It just simplifies it.

There really is no such thing as a static class. There are static methods in a class and there might be static variables attached to the class, but no such thing as a static class. When you hear static think ONE. There is only ONE instance of the static item. That static item will always be attached to the class. If its a static method, then that method is the only one in existance. If its a static variable, then that variable is the only instance.

Try checking out singletons.

Hope that helps.
[ May 26, 2004: Message edited by: Dale DeMott ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic