Separators in Java Programming

Separators in Java Programming

Previous Home Next

 

Separators help define the structure of a program.
The separators used in java program are parentheses, ( ), braces, { }, the period, ., and the semicolon,

Separators help define the structure of a program.
The separators used in java program are parentheses, ( ), braces, { }, the period, ., and the semicolon,

( )     Encloses arguments in method definitions and calling;
{ }     defines blocks of code and automatically initializes arrays
[ ]     declares array types and dereferences array values
;     terminates statements
,     separates successive identifiers in variable declarations
.     Selects a field or method from an object; separates package names from sub-package and class names
:     Used after loop labels


HOW TO USE SEPARATOR
another way to add separator is to use JSEPARATOR class used to add horizontal and vertical lines to the menu and tool bar

 

The code to add the menu items and separators to the menu is extremely simple, boiling down to something like this: 

 
menu.add(menuItem1);
menu.add(menuItem2);
menu.add(menuItem3);
menu.addSeparator();
menu.add(rbMenuItem1);
menu.add(rbMenuItem2);
menu.addSeparator();
menu.add(cbMenuItem1);
menu.add(cbMenuItem2);
menu.addSeparator();
menu.add(submenu);

Previous Home Next