Re: swap method in Java
From: Stefan Ram (ram_at_zedat.fu-berlin.de)
Date: 06/22/04
- Next message: Murrgon: "Re: How does javac.exe work?"
- Previous message: Bryce: "Re: Java Virtual File System"
- In reply to: Bill Reyn: "swap method in Java"
- Next in thread: Chris Smith: "Re: swap method in Java"
- Reply: Chris Smith: "Re: swap method in Java"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 22 Jun 2004 21:47:53 GMT
breyn12345@hotmail.com (Bill Reyn) writes:
>/* this swaps 2 integers correctly, BUT its seems non-OO */
>class Swap4
>{
> static int x=5, y=7 ; // this looks horrid!
> public static void main(String [] args){
> WorkItOut w = new WorkItOut();
> w.swaps(x,y);
>System.out.println( " x (was 5)now is " + x + " y (was 7) now is " + y);
> }
When is it not applicable to swap the variable names in
the rest of the block? I.e.,
class Swap4a
{ final static int x=5, y=7 ;
public static void main( final String[] args )
{ System.out.println( "x now is " + y + " y now is " + x ); }}
- Next message: Murrgon: "Re: How does javac.exe work?"
- Previous message: Bryce: "Re: Java Virtual File System"
- In reply to: Bill Reyn: "swap method in Java"
- Next in thread: Chris Smith: "Re: swap method in Java"
- Reply: Chris Smith: "Re: swap method in Java"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
Loading