Raised This Month: $12 Target: $400
 3% 

Java


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-13-2012 , 12:24   Java
Reply With Quote #1

Have to instantiate an object in order to format a number?




Also,

__________________

Last edited by Dr. McKay; 04-13-2012 at 12:26.
Dr. McKay is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 04-13-2012 , 12:42   Re: Java
Reply With Quote #2

I get the feeling that you do not like Java.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-13-2012 , 16:09   Re: Java
Reply With Quote #3

Quote:
Originally Posted by Dr. McKay View Post
Have to instantiate an object in order to format a number?
If you don't like Java, why not just use C# or something else instead?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-13-2012 , 16:11   Re: Java
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
If you don't like Java, why not just use C# or something else instead?
I'm in a Java class... (no pun intended)
__________________
Dr. McKay is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-13-2012 , 16:15   Re: Java
Reply With Quote #5

Quote:
Originally Posted by Dr. McKay View Post
I'm in a Java class... (no pun intended)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-13-2012 , 16:27   Re: Java
Reply With Quote #6

Quote:
Originally Posted by Dr. McKay View Post
Have to instantiate an object in order to format a number?
As a side note, you're not instantiating an object as much as asking the provider for the NumberFormat abstract class to do it for you. For that matter, having not looked at the SPI code for NumberFormat, it could easily cache the instances of the various NumberFormats for the default locale, so calling getInstance only gets you a reference to an already allocated object.

Personally, I think that'd be a dumb way to do it, but meh.

Anyway, I mentioned C# because it has .ToString overloads to do formatting on the various number types. Then again, all number types in C# are structs rather than primitives.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-13-2012 , 17:20   Re: Java
Reply With Quote #7

I'm just not a huge fan of exclusively object-oriented programming.

I like my linear stuff...

Or at least the ability to use objects if I so choose.

Also,
Code:
NumberFormat format = new NumberFormat("###.##");
String formatted = format.format(100);
As opposed to
PHP Code:
$formatted number_format(1002); 
__________________

Last edited by Dr. McKay; 04-13-2012 at 17:20.
Dr. McKay is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-13-2012 , 17:37   Re: Java
Reply With Quote #8

Quote:
Originally Posted by Dr. McKay View Post
I'm just not a huge fan of exclusively object-oriented programming.
Java is entirely object-oriented with the exception of its primitive variable types. C# is entirely object-oriented.

Not surprisingly, you use objects for nearly everything except for operators and keywords.

Quote:
Originally Posted by Dr. McKay View Post
Or at least the ability to use objects if I so choose.
PHP Code:
$formatted number_format(1002); 
Don't even get me started about PHP.

Quote:
Originally Posted by Dr. McKay View Post
Code:
NumberFormat format = new NumberFormat("###.##");
String formatted = format.format(100);
As a side note, that class on the right side should be DecimalFormat as NumberFormat is an abstract class.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-13-2012 at 17:39.
Powerlord is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-13-2012 , 17:42   Re: Java
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
Don't even get me started about PHP.
lol, I love PHP.

Quote:
Originally Posted by Powerlord View Post
As a side note, that class on the right side should be DecimalFormat as NumberFormat is an abstract class.
Yeah, I meant that...

Don't have the library of Java memorized, nor do I intend to. I'd much rather go and learn C++.
__________________
Dr. McKay is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode