Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Returning an integer value in java. Help!
New Posts  All Forums:Forum Nav:

Returning an integer value in java. Help!

post #1 of 4
Thread Starter 
The fact that I'm unable to return an integer is extremely annoying. Please help me out here. No matter what I write, Eclipse says that the return statement is missing. The code's given below.
Code:
public int indexOfFile(String filename){
for(int i=0;i<DRIVE_SIZE;i++){
String name=drive[i].getName();
if(filename==name){
return i;
}
else{
return -1;
}
}
}
I am supposed to return either '-1' or the value of 'i'. Thanks in advance.
First build
(13 items)
 
Pandoras Box
(13 items)
 
NV57H
(6 items)
 
CPUMotherboardGraphicsRAM
Phenom II X4 965 BE 4.0GHz @ 1.385V ASRock 970 Extreme 3 Gigabyte 650 Ti boost Mushkin Enhanced Silverline 4GB DDR3 1600 MHz 
RAMHard DriveOptical DriveCooling
Mushkin Enhanced Silverline 4GB DDR3 1600 MHz Seagate Barracuda 160GB  Samsung Noctua NH-D14 
MonitorPowerCaseMouse
Acer X223W Corsair VX550 Cooler Master Elite 430 TT E-Sports Theron 
Mouse Pad
Steelseries QcK Portal 2 
CPUMotherboardGraphicsRAM
E7500 @2.93 GHz Gigabyte G41M-ES2L Gigabyte HD 4650 2x 2 GB TwinMOS @ 800MHz 
Hard DriveOSMonitorPower
Samsung HD502IJ 500GB Windows 7 Ultimate 32-bit Samsung SyncMaster 943 18.5" Stock 450W 
Case
some piece of junk... 
CPUMotherboardGraphicsRAM
i3-2310M HM65 Intel HD 3000 6 GB DDR3 
Hard DriveOS
750 GB Windows 7 Home Premium x64 
  hide details  
Reply
First build
(13 items)
 
Pandoras Box
(13 items)
 
NV57H
(6 items)
 
CPUMotherboardGraphicsRAM
Phenom II X4 965 BE 4.0GHz @ 1.385V ASRock 970 Extreme 3 Gigabyte 650 Ti boost Mushkin Enhanced Silverline 4GB DDR3 1600 MHz 
RAMHard DriveOptical DriveCooling
Mushkin Enhanced Silverline 4GB DDR3 1600 MHz Seagate Barracuda 160GB  Samsung Noctua NH-D14 
MonitorPowerCaseMouse
Acer X223W Corsair VX550 Cooler Master Elite 430 TT E-Sports Theron 
Mouse Pad
Steelseries QcK Portal 2 
CPUMotherboardGraphicsRAM
E7500 @2.93 GHz Gigabyte G41M-ES2L Gigabyte HD 4650 2x 2 GB TwinMOS @ 800MHz 
Hard DriveOSMonitorPower
Samsung HD502IJ 500GB Windows 7 Ultimate 32-bit Samsung SyncMaster 943 18.5" Stock 450W 
Case
some piece of junk... 
CPUMotherboardGraphicsRAM
i3-2310M HM65 Intel HD 3000 6 GB DDR3 
Hard DriveOS
750 GB Windows 7 Home Premium x64 
  hide details  
Reply
post #2 of 4
Thread Starter 
Never mind. Got it right smile.gif
First build
(13 items)
 
Pandoras Box
(13 items)
 
NV57H
(6 items)
 
CPUMotherboardGraphicsRAM
Phenom II X4 965 BE 4.0GHz @ 1.385V ASRock 970 Extreme 3 Gigabyte 650 Ti boost Mushkin Enhanced Silverline 4GB DDR3 1600 MHz 
RAMHard DriveOptical DriveCooling
Mushkin Enhanced Silverline 4GB DDR3 1600 MHz Seagate Barracuda 160GB  Samsung Noctua NH-D14 
MonitorPowerCaseMouse
Acer X223W Corsair VX550 Cooler Master Elite 430 TT E-Sports Theron 
Mouse Pad
Steelseries QcK Portal 2 
CPUMotherboardGraphicsRAM
E7500 @2.93 GHz Gigabyte G41M-ES2L Gigabyte HD 4650 2x 2 GB TwinMOS @ 800MHz 
Hard DriveOSMonitorPower
Samsung HD502IJ 500GB Windows 7 Ultimate 32-bit Samsung SyncMaster 943 18.5" Stock 450W 
Case
some piece of junk... 
CPUMotherboardGraphicsRAM
i3-2310M HM65 Intel HD 3000 6 GB DDR3 
Hard DriveOS
750 GB Windows 7 Home Premium x64 
  hide details  
Reply
First build
(13 items)
 
Pandoras Box
(13 items)
 
NV57H
(6 items)
 
CPUMotherboardGraphicsRAM
Phenom II X4 965 BE 4.0GHz @ 1.385V ASRock 970 Extreme 3 Gigabyte 650 Ti boost Mushkin Enhanced Silverline 4GB DDR3 1600 MHz 
RAMHard DriveOptical DriveCooling
Mushkin Enhanced Silverline 4GB DDR3 1600 MHz Seagate Barracuda 160GB  Samsung Noctua NH-D14 
MonitorPowerCaseMouse
Acer X223W Corsair VX550 Cooler Master Elite 430 TT E-Sports Theron 
Mouse Pad
Steelseries QcK Portal 2 
CPUMotherboardGraphicsRAM
E7500 @2.93 GHz Gigabyte G41M-ES2L Gigabyte HD 4650 2x 2 GB TwinMOS @ 800MHz 
Hard DriveOSMonitorPower
Samsung HD502IJ 500GB Windows 7 Ultimate 32-bit Samsung SyncMaster 943 18.5" Stock 450W 
Case
some piece of junk... 
CPUMotherboardGraphicsRAM
i3-2310M HM65 Intel HD 3000 6 GB DDR3 
Hard DriveOS
750 GB Windows 7 Home Premium x64 
  hide details  
Reply
post #3 of 4
You must have a return outside of any condition.
post #4 of 4
Thread Starter 
Yeah. I realized that when I looked at the code again. Thanks smile.gif
First build
(13 items)
 
Pandoras Box
(13 items)
 
NV57H
(6 items)
 
CPUMotherboardGraphicsRAM
Phenom II X4 965 BE 4.0GHz @ 1.385V ASRock 970 Extreme 3 Gigabyte 650 Ti boost Mushkin Enhanced Silverline 4GB DDR3 1600 MHz 
RAMHard DriveOptical DriveCooling
Mushkin Enhanced Silverline 4GB DDR3 1600 MHz Seagate Barracuda 160GB  Samsung Noctua NH-D14 
MonitorPowerCaseMouse
Acer X223W Corsair VX550 Cooler Master Elite 430 TT E-Sports Theron 
Mouse Pad
Steelseries QcK Portal 2 
CPUMotherboardGraphicsRAM
E7500 @2.93 GHz Gigabyte G41M-ES2L Gigabyte HD 4650 2x 2 GB TwinMOS @ 800MHz 
Hard DriveOSMonitorPower
Samsung HD502IJ 500GB Windows 7 Ultimate 32-bit Samsung SyncMaster 943 18.5" Stock 450W 
Case
some piece of junk... 
CPUMotherboardGraphicsRAM
i3-2310M HM65 Intel HD 3000 6 GB DDR3 
Hard DriveOS
750 GB Windows 7 Home Premium x64 
  hide details  
Reply
First build
(13 items)
 
Pandoras Box
(13 items)
 
NV57H
(6 items)
 
CPUMotherboardGraphicsRAM
Phenom II X4 965 BE 4.0GHz @ 1.385V ASRock 970 Extreme 3 Gigabyte 650 Ti boost Mushkin Enhanced Silverline 4GB DDR3 1600 MHz 
RAMHard DriveOptical DriveCooling
Mushkin Enhanced Silverline 4GB DDR3 1600 MHz Seagate Barracuda 160GB  Samsung Noctua NH-D14 
MonitorPowerCaseMouse
Acer X223W Corsair VX550 Cooler Master Elite 430 TT E-Sports Theron 
Mouse Pad
Steelseries QcK Portal 2 
CPUMotherboardGraphicsRAM
E7500 @2.93 GHz Gigabyte G41M-ES2L Gigabyte HD 4650 2x 2 GB TwinMOS @ 800MHz 
Hard DriveOSMonitorPower
Samsung HD502IJ 500GB Windows 7 Ultimate 32-bit Samsung SyncMaster 943 18.5" Stock 450W 
Case
some piece of junk... 
CPUMotherboardGraphicsRAM
i3-2310M HM65 Intel HD 3000 6 GB DDR3 
Hard DriveOS
750 GB Windows 7 Home Premium x64 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Returning an integer value in java. Help!