[COLOR=#a020f0]package[/color] examples;
[COLOR=#2e8b57][b]class[/b][/color] GlobalConstants{
[COLOR=#2e8b57][b]static[/b][/color] [COLOR=#2e8b57][b]int[/b][/color] OVERALL_SIZE = [COLOR=#ff00ff]15[/color];
[COLOR=#2e8b57][b]static[/b][/color] [COLOR=#2e8b57][b]int[/b][/color] ONE_SIZE = OVERALL_SIZE - [COLOR=#ff00ff]8[/color];
[COLOR=#2e8b57][b]static[/b][/color] [COLOR=#2e8b57][b]int[/b][/color] TWO_SIZE = OVERALL_SIZE - [COLOR=#ff00ff]4[/color];
}
[COLOR=#2e8b57][b]class[/b][/color] One [COLOR=#2e8b57][b]extends[/b][/color] GlobalConstants{
[COLOR=#2e8b57][b]public[/b][/color] [COLOR=#2e8b57][b]int[/b][/color] onea;
[COLOR=#2e8b57][b]public[/b][/color] [COLOR=#2e8b57][b]int[/b][/color] oneb;
[COLOR=#2e8b57][b]public[/b][/color] [COLOR=#2e8b57][b]byte[/b][/color][] mdata = [COLOR=#804040][b]new[/b][/color] [COLOR=#2e8b57][b]byte[/b][/color][ONE_SIZE];
}
[COLOR=#2e8b57][b]class[/b][/color] Two [COLOR=#2e8b57][b]extends[/b][/color] GlobalConstants{
[COLOR=#2e8b57][b]public[/b][/color] [COLOR=#2e8b57][b]float[/b][/color] twoa;
[COLOR=#2e8b57][b]public[/b][/color] [COLOR=#2e8b57][b]byte[/b][/color][] mdata = [COLOR=#804040][b]new[/b][/color] [COLOR=#2e8b57][b]byte[/b][/color][TWO_SIZE];
}
[COLOR=#2e8b57][b]public[/b][/color] [COLOR=#2e8b57][b]class[/b][/color] MyStructures [COLOR=#2e8b57][b]extends[/b][/color] GlobalConstants{
[COLOR=#2e8b57][b]public[/b][/color] [COLOR=#2e8b57][b]static[/b][/color] [COLOR=#2e8b57][b]void[/b][/color] main(String args[]) {
[COLOR=#0000ff]// Create Instance of structure One[/color]
One structOne = [COLOR=#804040][b]new[/b][/color] One();
[COLOR=#0000ff]// Filling Values[/color]
structOne.onea = [COLOR=#ff00ff]1[/color];
structOne.oneb = [COLOR=#ff00ff]2[/color];
[COLOR=#804040][b]for[/b][/color] ([COLOR=#2e8b57][b]int[/b][/color] i=[COLOR=#ff00ff]0[/color]; i<=ONE_SIZE-[COLOR=#ff00ff]1[/color]; i++){
structOne.mdata[i]=([COLOR=#2e8b57][b]byte[/b][/color])(Math.random()*[COLOR=#ff00ff]255[/color]);
}
[COLOR=#0000ff]// Printing Values[/color]
System.out.println([COLOR=#ff00ff]"Components of StructOne:"[/color]);
System.out.format([COLOR=#ff00ff]"structOne.onea = %2d[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color], structOne.onea);
System.out.format([COLOR=#ff00ff]"structOne.oneb = %2d[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color], structOne.oneb);
System.out.format([COLOR=#ff00ff]"ONE_SIZE = %2d[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color], ONE_SIZE);
[COLOR=#804040][b]for[/b][/color] ([COLOR=#2e8b57][b]int[/b][/color] i=[COLOR=#ff00ff]0[/color]; i<=ONE_SIZE-[COLOR=#ff00ff]1[/color]; i++){
System.out.format([COLOR=#ff00ff]"structOne.mdata[%02d] = %3d[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color], i, structOne.mdata[i]);
}
[COLOR=#0000ff]// Create Instance of the structure Two[/color]
Two structTwo = [COLOR=#804040][b]new[/b][/color] Two();
[COLOR=#0000ff]// Filling Values[/color]
structTwo.twoa = [COLOR=#ff00ff]3[/color];
[COLOR=#804040][b]for[/b][/color] ([COLOR=#2e8b57][b]int[/b][/color] i=[COLOR=#ff00ff]0[/color]; i<=TWO_SIZE-[COLOR=#ff00ff]1[/color]; i++){
structTwo.mdata[i]=([COLOR=#2e8b57][b]byte[/b][/color])([COLOR=#2e8b57][b]byte[/b][/color])(Math.random()*[COLOR=#ff00ff]255[/color]);
}
[COLOR=#0000ff]// Printing Values[/color]
System.out.println([COLOR=#ff00ff]"[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]Components of StructTwo:"[/color]);
System.out.format([COLOR=#ff00ff]"structTwo.twoa = %f[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color], structTwo.twoa);
System.out.format([COLOR=#ff00ff]"TWO_SIZE = %2d[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color], TWO_SIZE);
[COLOR=#804040][b]for[/b][/color] ([COLOR=#2e8b57][b]int[/b][/color] i=[COLOR=#ff00ff]0[/color]; i<=TWO_SIZE-[COLOR=#ff00ff]1[/color]; i++){
System.out.format([COLOR=#ff00ff]"structTwo.mdata[%02d] = %3d[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color], i, structTwo.mdata[i]);
}
}
}