Useful Java Code Snippets


TreeMap/TreeSet

ArrayDeque

  • As stack or queue:
  • its default iterator or stream is a queue: fifo
  • Use iterator, for loop to access it, but not support random access like get(i)

Stream

Optional

Avoid null check

Collection

Misc

CSS Tips and Tricks


CSS Tips and Tricks

CSS Selectors

.class1.class2<div class="name1 name2">...</div>Selects all elements with both name1 and name2 set within its class attribute
.class1 .class2<div class="name1"><div class="name2">Selects all elements with name2 that is a descendant of an element with name1
element,elementdiv, pSelects all <div> elements and all <p> elements
element elementdiv pSelects all <p> elements inside <div> elements

Background Images

.post-body {
  background-color: #336655;
  background-image: url("https://cdn12.picryl.com/photo/2016/12/31/cat-black-cat-black-animals-5ef19b-1024.jpg");
  background-repeat: no-repeat;
}

Use a CSS Class to Style an Element

<style>
  .blue-text {
    color: blue;
  }
</style>
<h2 class="blue-text">CatPhotoApp</h2>

Blockquotes CSS

blockquote {
 margin: 0;
 border-left: 3px solid #ccc;
}
blockquote p {
 padding: 15px;
 background: #eee;
 border-radius: 5px;
}
blockquote p::before {content: '\201C';}
blockquote p::after {content: '\201D';}

Table CSS

.post-body table {
  border-collapse: collapse;
}
.post-body table, th, td {
  border: 1px solid black;
}

Center

.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 50%;
}

Websites for Programmers to Visit


Gson Essentials


References

Jackson Essentials

Labels

adsense (5) Algorithm (69) Algorithm Series (35) Android (7) ANT (6) bat (8) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) Java (186) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)