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 (4) ANT (6) bat (8) Become a Better You (4) Big Data (7) Blogger (14) Bugs (4) Cache (5) Chrome (17) Code Example (29) Code Quality (6) Coding Skills (5) Concurrency (4) Database (7) Debug (16) Design (5) Dev Tips (62) Eclipse (32) GAE (4) Git (5) Good Programming Practices (4) Google (27) Guava (7) How to (9) Http Client (8) IDE (6) Interview (88) J2EE (13) J2SE (49) Jackson (4) Java (177) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (22) Lucene-Solr (112) Mac (10) Maven (8) Memory Usage (4) Network (9) Nutch2 (18) OpenNLP (4) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Review (4) Scala (6) Security (9) Soft Skills (38) Spark (4) Spring (22) System Design (11) Testing (6) Text Mining (14) Tips (12) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)

Trending