New Posts  All Forums:Forum Nav:

im stuck in java - Page 2

post #11 of 35
Yeah tell me about it lol ive been slowly reading through it at the moment, some of the functions are quite good though.
Roof Ski
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 950 @4ghz HT on 1v XFX X58I SLi 295's 12GB OCZ Obsidian 1600mhz 
Hard DriveOptical DriveOSMonitor
ocz agility 3 + 4TB Drives Samsung DVD-RW Win 7 Ultimate x64 2x Samsung 24"s + DELL E248WFP 
KeyboardPowerCaseMouse
G11 Sleeved corsair ax850 800D Sidewinder 
  hide details  
Reply
Roof Ski
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7 950 @4ghz HT on 1v XFX X58I SLi 295's 12GB OCZ Obsidian 1600mhz 
Hard DriveOptical DriveOSMonitor
ocz agility 3 + 4TB Drives Samsung DVD-RW Win 7 Ultimate x64 2x Samsung 24"s + DELL E248WFP 
KeyboardPowerCaseMouse
G11 Sleeved corsair ax850 800D Sidewinder 
  hide details  
Reply
post #12 of 35
Thread Starter 
man im gonna break someones face right now ive never hit a wall this hard before
post #13 of 35
A method is a function that you can call with parameters that you can pass in and return values.

Example:
Code:
public class MethodExample
{
  public static void main(String args[])
  {
    say("foo");
  }

  public void say(String msg)
  {
    System.out.println(msg);
  }

  public String sayBack(String msg)
  {
    System.out.println(msg);
    return msg;
  }
}
Here is some information on methods: http://download.oracle.com/javase/tu...O/methods.html
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
post #14 of 35
Thread Starter 
ok so in my package or lab folder i have a main.java is that a method? or is the " public class Main { " my method line and can i just add them to the document??
post #15 of 35
Thread Starter 
and waht is all this public and void crap going on XD im so gonna fail XD
post #16 of 35
The main.java file is the main file in your project. The "public class Main { }" defines the class Main. Inside that class there should be a function called "main" which will be called when you run the program, this is where everything starts from. (It should be: public static void main(String args[]){ })

You can define new methods inside the curly brackets for the Main class using the following syntax: method visibility then return type then method name (input parameters)

So like:
public void MethodExample(String s1, String s2)

Would be a publicly visible method, with no return value that accepts two strings as input parameters.
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
post #17 of 35
Quote:
Originally Posted by Onions View Post
and waht is all this public and void crap going on XD im so gonna fail XD
I would suggest you read this: http://www.cse.yorku.ca/~mack/1011/MethodSyntax.PDF

The section Method Signature on page 2 does a very good job of explaining the modifiers that are used when declaring methods.
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
post #18 of 35
Thread Starter 
ok so i can have many methods in a class? they work like functions so i can call them when ever i want??
post #19 of 35
That's right, you can have as many methods in a class as you want afiak. You can call them as long as they're visible to wherever you want to call them. For example, you can't call a private method unless you're calling it from another method in the same class.
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
GhostBox
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 (Lapped) @ 3825MHz EVGA 780i FTW 2xSLI - EVGA GTX260 (216) 4x2GB OCZ Reaper @ 5-5-5-18 2.1V 
Hard DriveOptical DriveOSMonitor
320GB Seagate RAID 1: 2TB WD Samsung 20X DVD+R Vista Ultimate x64, Ubuntu 8.10 x64 Acer P244W x2 
KeyboardPowerCaseMouse
IBM Model M Corsair 850HX CoolerMaster Stacker 810 (Modded) Razer Copperhead 
Mouse Pad
SteelSeries QcK 
  hide details  
Reply
post #20 of 35
Thread Starter 
ok ok i get it so for my project i need to add two fractions together so i would ask for all four numbers then send the two numeratoors to one method and the two denominators to another to be able to get teh greatest common factor right??
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming