Java Glossary : block

CMP home Java glossary home Menu no menu Last updated 2004-06-28 by Roedy Green ©1996-2004 Canadian Mind Products

Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

You are here : home : Java Glossary : B words : block.

block
In Pascal blocks are subpieces of a method that have local variables. Java for loops are considered new scope blocks where you can initialise one local variable in the for loop. You can also define a block in Java just by enclosing the code in{}. Local variables defined inside{} are not known outside the block, though they are allocated when the method starts, not when the block is entered. In other words there is no speed penalty for declaring a local variable inside a loop. A new stack frame is not started for each block. Smalltalk programmers us the term "block" to mean a little fragment of code that you can store in a variable or pass as a parameter. Even if statements can use blocks for the ifTrue and ifFalse actions. Blocks also provide a slick way of invoking an enumeration of a collection, running some code on each element of a set. In contrast to Smalltalk, Java has a rather verbose way for requesting a piece of code be executed on each element of a collection using the Enumeration class.

The term has quite a different used in datacommunications: Modern file transfer protocols send data in blocks, or packets, rather than just a byte at a time. Usually, the larger the block size the more efficient the file transfer. This is because most file transfer protocols wait for an acknowledgement from the other end after each block is sent, so larger blocks mean fewer stops for handshaking. However having blocks too big slows things down. This is because a single error means the whole block must be re-transmitted. Not only do the blocks take longer to retransmit, there is an increased change for error in each block.


CMP logo
CMP_home
home
Canadian Mind Products CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[24.87.56.253]
Your IP:[80.134.30.163]
You are visitor number 825.
Please send errors, omissions and suggestions
to improve this page to Roedy Green.
You can get a fresh copy of this page from: or possibly from your local J: drive mirror:
http://mindprod.com/jgloss/block.html J:\mindprod\jgloss\block.html