Wikipedia

Search results

Tuesday, April 9, 2019

10 Java Tricks Every Programmer Should Know



When you talk about Object Oriented Programming, the best and the most apt example that comes to the mind is Java. Developed by Sun Microsystems, Java leads the way in terms of cross platform programming language and developing application software. 


 Being a good Java developer is always within touching distance of any computer programming enthusiast, however; it is standing amongst the very bests that matters. 
Below are some tips that might help you grow as a Java developer and gain more knowledge about the language. 
More than 9 Million developers choose to write their code in Java and it is very popular among developers as well as being the most popular development platform.

  • See Your Shortcuts In Eclipse:-  

 Here’s one for all you novice developers we’ll start with something simple before we start getting into the real secrets. While programming in the Eclipse framework, you can press Ctrl+Shift+L to bring up a widget that displays every available shortcut key. Though this is a fairly simple shortcut – and perhaps not as unknown as some others on the list – it’s still a fantastic one to be aware of.

  • Cut Down On String Size:-

If you’re looking to optimize Java’s performance, packing your strings is a great place to start – especially if you’re storing a great deal of them in memory. The Java Performance Tuning Guide provides a few great tactics for lowering the size of your strings – and increasing the performance of your installation.

  • Use JDK 8 or Higher Version:-

From JDK 8 and later, many new features introduced will allow you to write shorter and more expressive code, including lambda expressions, functional interfaces, stream APIs, and more. You don’t need to remember them actually, as IDEA will assist you to use this features, that’s another reason why you should use IDEA. “Java 8 in Action” might be of some help to you.

  • Avoiding Memory leaks:-

Memory leaks often cause performance degradation of software. Since, Java manages memory automatically, the developers do not have much control. But there are still some standard practices which can be used to protect from memory leakages.
Always release database connections when querying is complete.
Try to use Finally block as often possible.
Release instances stored in Static Tables


Monday, April 1, 2019

CardLayout in java

Home 
  • Cardlayout in java :-
A CardLayout object is a layout manager for a container. It treats each component in the container as a card. Only one card is visible at a time.. The first component added to a CardLayout object is the visible component when the container is first displayed.

  • Constructors of CardLayout :-
1.public CardLayout()


Creates a new card layout with gaps of size zero. 

2.CardLayout(int hgap, int vgap)
Creates a new card layout with the specified horizontal and vertical gaps.

Some of the methods of  CardLayout are:-




Methods




Description
public  first(Container parent)Shows the first card of the parent container
public next(Container parent)Shows the next card of the parent containerIf the current visible card is the last one, it will flip to the first one.
public previous(Container parent)Shows to the previous card of the parent container. If the current visible card is the first one, it will flip to the last one.
public  last(Container parent)Show the last card of the parent container.
public  show(Container parent,String name)Show the card with a given name.