Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- static nested class



  static nested and non-static nested class in Java

Nested classes are divided into two categories: static and non-static(inner). Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes. Static class can be defined as : class OuterClass{ static class StaticNestedClass{ //OTHER STUFF } } Static nested classes are accessed using the enclosing class name: OuterClass.StaticNestedClass For example, to create an object for the static nested class, use this synta...

   Java,static nested class,inner class     2014-04-23 07:11:44

  Inline IF and CASE statements in MySQL

There are times where running IF statements inside a query can be useful. MySQL provides a simple way to do this through the use of IF and CASE statements. The IF statement takes three arguments; the conditional, the true value and the false value. False and true values may be static values or column values. For example: SELECT IF(score > 100, 100, score) AS score FROM exam_results this will return the value in the score column limited to a maximum value of 100. IF statements can a...

   MySQK,IF,Condition,CASE,SQL     2012-04-22 10:37:01

  Configure static IP for Linux

When a Linux server is running, it has to have an IP so that other machines can talk to it. It is often desired that the server would own a static IP so that every time other machines want to connect to it, the same IP address would be used. This is extremely useful when there are virtual machines installed on a host machine where the virtual machine would start and stop now and then.  To configure static IP address for a Linux server, the /etc/network/interfaces needs to be updated. Assumi...

   LINUX,NETWORK,STATIC IP,DNS     2017-07-08 08:39:58

  CSS DIV position analysis

When using CSS to set the position of DIV, we may often get confused with the 4 position properties : static, relative, absolute and fixed. If we don't understand them correctly, we may often get unexpected result. Here we make some analysis to them.The definitions of these 4 properties:static : The default position property. It has no position actually. The element will appear where it should be (top, bottom, left, right or z-index has no use here)relative : This one will position relati...

   CSS, DIV,position,relative,absolute     2013-01-29 03:23:57

  How key-based cache expiration works

There are only two hard things in Computer Science: cache invalidation and naming things — Phil Karlton Doing cache invalidation by hand is an incredibly frustrating and error-prone process. You’re very likely to forget a spot and let stale data get served. That’s enough to turn most people off russian-doll caching structures, like the one we’re using for Basecamp Next. Thankfully there’s a better way. A much better way. It’s called key-based cac...

   Cache,Expiration,Key-base cache,Work     2012-02-20 05:32:40

  A strange behavior of printing struct with nested struct in GoLang

Normally when trying to print a struct , we would use %v to show all data of the struct. It will print the default format for each field in the struct. %v the value in a default format when printing structs, the plus flag (%+v) adds field names But recently we observed a strange behavior when printing a struct with nested struct which has a String() string implemented, the %v format prints an 'unexpected' output per our understanding.   Let's see the example snippet first. pa...

   PROGRAMMING,GOLANG     2018-10-29 09:59:49

  Recursive class initialization in Java

When a Java class is referenced and initialized, it has to go through the loading and linking first. Once the loading and linking complete successfully. The class will be initialized. The static variables and constant variables will be initialized during this process. Once the class is initialized, it is ready for use. If when class A is initialized and it is referencing a class B, the class B will also get initialized. But what will happen if class B is referencing class A as well? This is call...

   Java,JVM,class initialization,static final     2015-04-15 21:04:29

  Using Java keytool programmatically

Java provides a command line tool to access and operate different keystore which store keys and certificates. This tool is named keytool and is located at \bin.  On command line, you can issue below command to generate a keystore named mytest.jks which contains a private key and certificate chain. keytool -genkeypair -alias mykey -keyalg RSA -sigalg SHA256withRSA -dname CN=Java -storetype JKS -keypass password -keystore mytest.jks -storepass password Sometimes, in testing purpose, w...

   JAVA,KEYTOOL     2016-01-09 06:28:07

  Access control in Java -- doPrivileged

Previously we have introduced how Java performs permission check to protect resource access. What if sometimes we need to give some class the temporary access to some resource which it initially doesn't have? AccessController provides six doPrivileged methods to fulfill this requirement. These six methods have below signatures : static T doPrivileged(PrivilegedAction action)static T doPrivileged(PrivilegedAction action, AccessControlContext context)static T doPrivileged(PrivilegedExceptionA...

   JAVA,SECURITY,DOPRIVILEGED     2016-03-08 05:46:42

  Replacing small C programs with Haskell

C is the classic go-to tool for small programs that need to be really fast. When scripts.mit.edu needed a small program to be a glorified cat that also added useful HTTP headers to the beginning of its output, there was no question about it: it would be written in C, and it would be fast; the speed of our static content serving depended on it! (The grotty technical details: our webserver is based off of a networked filesystem, and we wanted to avoid giving Apache too many credentials in ca...

   C,Haskell,Small program     2012-01-03 10:51:39