MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides  
Homepage Register FAQ Members Mark Forums Read Advertise Marketplace FPSowned


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > Programming > Programming section > Java
Reload this Page Hello World!
Java Discussions about Java

Reply
 
LinkBack Thread Tools
Hello World!
(#1)
Old
Pragma's Avatar
Pragma is Offline
Contributor
Rep Power: 3
Reputation: 260
Pragma is a jewel in the roughPragma is a jewel in the roughPragma is a jewel in the rough
 
Posts: 608
Join Date: Feb 2007
Location: int main()
Codes Hello World! - 03-10-2008

Here is a simple script that when run displays "Hello World!" into the commands prompt. More will be explained about it after.

Code:
public class Hello
{
      public static void main(String[] args)
      {
             System.out.println("Hello World!");
      }
}
"public static Hello" is defining the class to be:
public (Can be accessed by other classes)
static (can be access inside this file)
and to be named "Hello" (NOTE!: your file must be named the same as the class that contains the main method header, which in this case would be the Hello class)

"public static void main(String[] args)" is the main method header, any file that will be ran will need this method.
public (can be accessed by other classes or methods)
static (can be accessed by the rest of this class or other methods in this class)
void (the method's return type)


I must go for now but soon I will post a guide on compiling and running a java class file in a windows OS.




Last edited by Pragma; 03-19-2008 at 10:58 PM..
Reply With Quote

Donate to remove ads.
(#2)
Old
Lahtaaja is Offline
Corporal
Rep Power: 1
Reputation: 8
Lahtaaja is an unknown quantity at this point
 
Posts: 29
Join Date: Jan 2008
03-10-2008

This is legend
The first thing I learned about programming [if not counting endless hours sitting front of WC3 WE].
for you xD
Reply With Quote
(#3)
Old
cubed is Offline
Master Sergeant
Rep Power: 1
Reputation: 27
cubed is on a distinguished road
 
Posts: 81
Join Date: Feb 2008
03-19-2008

Quote:
Originally Posted by insanesk8123 View Post
Here is a simple script that when run displays "Hello World!" into the commands prompt. More will be explained about it after.

Code:
public static Hello
{
      public static void main(String[] args)
      {
             System.out.println("Hello World!");
      }
}
"public static Hello" is defining the class to be:
public (Can be accessed by other classes)
static (can be access inside this file)
and to be named "Hello" (NOTE!: your file must be named the same as the class that contains the main method header, which in this case would be the Hello class)

"public static void main(String[] args)" is the main method header, any file that will be ran will need this method.
public (can be accessed by other classes or methods)
static (can be accessed by the rest of this class or other methods in this class)
void (the method's return type)


I must go for now but soon I will post a guide on compiling and running a java class file in a windows OS.
Actually, you're wrong about half of the stuff in this post.

First off, "public static Hello" will not compile. You can't have a static modifier on a class, only public, abstract, and final.

Secondly, you said "static (can be accessed by the rest of this class or other methods in this class)" which is entirely wrong. The static modifier on a method in a class means that it can be accessed by anything, take for instance the Integer.parseInt(int x) method, which is static.

Anyway, you definitely don't deserve rep for this.
Reply With Quote
(#4)
Old
Pragma's Avatar
Pragma is Offline
Contributor
Rep Power: 3
Reputation: 260
Pragma is a jewel in the roughPragma is a jewel in the roughPragma is a jewel in the rough
 
Posts: 608
Join Date: Feb 2007
Location: int main()
03-19-2008

I meant to put public class Hello but everything else I said was correct soo would you kindly F*** off. =)

You don't even know what your talking about 'public' is what makes it accessible by everything.




Last edited by Pragma; 03-19-2008 at 11:05 PM..
Reply With Quote
(#5)
Old
Apoc's Avatar
Apoc is Offline
c|_| My care cup is empty
Legendary User
Rep Power: 6
Reputation: 762
Apoc is a splendid one to beholdApoc is a splendid one to beholdApoc is a splendid one to beholdApoc is a splendid one to beholdApoc is a splendid one to beholdApoc is a splendid one to beholdApoc is a splendid one to behold
 
Posts: 881
Join Date: Jan 2008
03-20-2008

Public simply makes the class accessible to the current assembly. "Accessible by everything" is a bad way of saying it.

""public static void main(String[] args)" is the main method header, any file that will be ran will need this method." While somewhat correct, again, bad wording. The "main" function is the entry point for the program. Anything you want to be run on startup, should be added here. (Usually this turns into a call to another method, which handles most of the startup tasks as the main method is usually hidden where it can't easily be tinkered with.) The compiler implicitly looks for the first occurrence of the "main" method to begin the application. (Keep in mind, you cannot have 2 of the same method names. Or member names for that matter.)

One more thing to keep in mind, "main" is not the same as "Main".

"Void" is not a return type per-se. Void is declaring that this method has NO return type. And should be executed without expecting anything in return.


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
Reply With Quote
(#6)
Old
jdismeuc's Avatar
jdismeuc is Offline
Contributor
Rep Power: 2
Reputation: 103
jdismeuc will become famous soon enoughjdismeuc will become famous soon enough
 
Posts: 478
Join Date: May 2007
Location: C:\\
03-20-2008

Or you could use html... lol


Reply With Quote
(#7)
Old
Pragma's Avatar
Pragma is Offline
Contributor
Rep Power: 3
Reputation: 260
Pragma is a jewel in the roughPragma is a jewel in the roughPragma is a jewel in the rough
 
Posts: 608
Join Date: Feb 2007
Location: int main()
03-22-2008

Quote:
Originally Posted by jdismeuc View Post
Or you could use html... lol
what that doesnt even make sense, you have to clue what were doing.



Reply With Quote
(#8)
Old
jdismeuc's Avatar
jdismeuc is Offline
Contributor
Rep Power: 2
Reputation: 103
jdismeuc will become famous soon enoughjdismeuc will become famous soon enough
 
Posts: 478
Join Date: May 2007
Location: C:\\
03-23-2008

Oh wow, sorry. I did not realize that this was all in Command Prompt. Maybe I should try reading? hmmm....


Reply With Quote
(#9)
Old
Pragma's Avatar
Pragma is Offline
Contributor
Rep Power: 3
Reputation: 260
Pragma is a jewel in the roughPragma is a jewel in the roughPragma is a jewel in the rough
 
Posts: 608
Join Date: Feb 2007
Location: int main()
03-24-2008

no its cool, didnt mean to get mad like that XD



Reply With Quote
Reply

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are On



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vBulletin Skin developed by: vBStyles.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382