aspose file tools
The moose likes Java in General and the fly likes maximum number of statements in a method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "maximum number of statements in a method" Watch "maximum number of statements in a method" New topic
Author

maximum number of statements in a method

John Mallavalli
Ranch Hand

Joined: Apr 24, 2002
Posts: 46
Hi,

Is there a limit for the number of statements in a java method or is it possible to have any number of statements in a java method ?

Thanks in advance.

John


Do not let what you cannot do interfere with what you can do !!<br /> <br />SCJP & SCWCD 1.4
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Technically I'm not aware of there being a restriction, but I would be wary of writing bloated methods performing more than one task and running into several hundered lines. Always best practice to split something up into several smaller methods to avoid confusing code. Also makes it easier to track bugs IMO.


SCJP 1.4, www.gsi3d.org.uk
John Mallavalli
Ranch Hand

Joined: Apr 24, 2002
Posts: 46
Yes..I understand that its a bad practice to have bloated methods. I just wanted to know if at all there is any restriction on the limit for the number of statements in a java method.
Anyway thanks for your response.

- John
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 244
I don't know if such limit exists but there's a maximum size of bytecode compiled method. It's 64KB.
[ August 26, 2004: Message edited by: Vlado Zajac ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12269
    
    1
As I recall, there is a limit on the size of a compiled method based on the number of byte codes - not the number of lines. I think the limit is due to the fact that jumps are coded in 16 bits so your compiled method must be less than 32K in size. This limitation should be familiar to anybody who has coded in assembly language.
Bill
John Mallavalli
Ranch Hand

Joined: Apr 24, 2002
Posts: 46
Thanks guys.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: maximum number of statements in a method
 
Similar Threads
Are the inline conditionals to tough for a junior programmer ?
How many statements we can open with that particular connection
Starting to open the connection at the beginning of the class
Assignment 1a
How many statements we can create from a single connection