For those that never see it nor use it or have heard of bitwise operations, this is great boolean operator:a |= b;is the same asa = a || b;It's a bitwise inclusive or assignment, use it all the time myself to make lines more readable, but have found fellow developers have never seen it. Now you have.IE:canHasCheeseBurger |= hasEnoughMoney;canHasCheeseBurger = canHasCheeseBurder || hasEnoughMoney;
For those that never see it nor use it or have heard of bitwise operations, this is great boolean operator
The Java programming language also provides operators that perform bitwise and bit shift operations on integral types. The operators discussed in this section are less commonly used. Therefore, their coverage is brief; the intent is to simply make you aware that these operators exist.The unary bitwise complement operator "~" inverts a bit pattern; it can be applied to any of the integral types, making every "0" a "1" and every "1" a "0". For example, a byte contains 8 bits; applying this operator to a value whose bit pattern is "00000000" would change its pattern to "11111111".The signed left shift operator "<<" shifts a bit pattern to the left, and the signed right shift operator ">>" shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension.The bitwise & operator performs a bitwise AND operation.The bitwise ^ operator performs a bitwise exclusive OR operation.The bitwise | operator performs a bitwise inclusive OR operation.The following program, BitDemo, uses the bitwise AND operator to print the number "2" to standard output.class BitDemo { public static void main(String[] args) { int bitmask = 0x000F; int val = 0x2222; // prints "2" System.out.println(val & bitmask); }}
enum Direction{ North = 0x1, South= 0x10, East = 0x100, West = 0x1000}
Direction SpaceMonkey = Direction.North;SpaceMonkey |= Direction.South;System.out.println(SpaceMonkey); //SpaceMonkey does the moonwalk.
I read the Wiki article on Bitwise operation.I don't see the point of it. In what real world situations would this be useful?
protected ImageIcon createIcon(int w,int h,AttributedString line){public void createButtons(){String[]HAND_SIGNS={"Fingers","Palm","Snap","Wave","Digit","Clap"};AttributedString[]letters = new AttributedString[HAND_SIGNS.length];Font font2 = new Font("Monotype Corsiva", Font.BOLD, 50);for(int i=0;i<HAND_SIGNS.length;i++){AttributedString a=new AttributedString(HAND_SIGNS[i].substring(0,1));a.addAttribute(TextAttribute.FONT, font2);letters[i]=a;}//4 hand_signs.lengthJButton[]btns=new JButton[letters.length];int w=100;for(int i=0;i<btns.length;i++){JButton btn=new JButton(createIcon(w,w,letters[i]));btn.setPreferredSize(new Dimension(w,w));btns[i]=btn;btn.setActionCommand(String.format("btn%s",HAND_SIGNS[i]));//btn.addActionListener(this);btns[i]=btn;}//4 btns.length}//method create buttonsprotected ImageIcon createIcon(int w,int h,AttributedString line){BufferedImage image=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);Graphics g = image.createGraphics();g.setColor(Color.BLACK);g.fillRect(0,0,w,h);g.setColor(Color.WHITE);g.drawString(line.getIterator(),25,70);//given a w=100,h=100: font size=50return new ImageIcon(image);}//me createIcon
If I am not mistaken, bitwise operations actually occur under the hood for normal operations, hence 3GL and 4GL languages don't need bitwise operators.
Fuck yes, my whole team can related to almost every single one:http://martinvalasek.com/blog/pictures-from-a-developers-life
Time(int hour, int minute, int second) - Deprecated. Use the constructor that takes a milliseconds value in place of this constructor
class TimeIndex extends java.sql.Time{// int hours;// int minutes;// int seconds;// @SuppressWarning("deprecated")protected int milliseconds;@SuppressWarnings("deprecation")public TimeIndex(){super(0,0,0);}//cpublic int getMilliseconds(){return milliseconds;}public void setMilliseconds(int n){if(n>999)n=0;milliseconds=n;}// public int getSeconds(){// return seconds;// }public String toString(){return String.format("%s,%d",super.toString(),milliseconds);}//toString}//class
Why is it called a JButton? Why not just a Button? Why does Java have to put a J in front of Jeverything?
import java.io.File;public class DirectoryReader{private String path;private String[]files;public DirectoryReader(){}//constructorpublic DirectoryReader(String path){try{this.path=path;File folder = new File(path);File[] listOfFiles = folder.listFiles();files=new String[listOfFiles.length];for (int i = 0; i < listOfFiles.length; i++) {if (listOfFiles[i].isFile()) {files[i]=listOfFiles[i].toString();}//if}//for}catch(NullPointerException npe){javax.swing.JOptionPane.showMessageDialog(null,npe .toString(),"Directory empty or does not exist!",javax.swing.JOptionPane.INFORMATION_MESSAGE);}//method}//constructorpublic String[] getImages(){return getFiles();}//methodpublic String[] getFiles(){return files;}//methodpublic int getSize(){return getLength();}//methodpublic int getLength(){return files.length;}//methodpublic String toString(){return "I am an object which can read directories!";}//method}//class
Programming zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz zzzzzzzz
I didn't think such thing as a java enthusiast existed.
Vessel: The vessel is chosen (whether by a deity or institution) for their paladin abilities. They are typically already martially proficient, or if they are not then they are typically trained to be so. Vessels have their own alignment however they must follow the whim of whoever granted them their abilities (which usually goes by a code of conduct similar to that of the zealot) or lose them altogether (fallen). Unlike the zealot, a vessel's abilities do not correspond to their alignment.CN - Chaotic Neutral paladins are identical to the chaotic good paladin listed above, with the addition that their smite is identical to the true neutral paladin's in how it functions.
In random developer news, I installed an incorrect crontab last night which resulted in a call from the georgian government this morning inquiring about a possible cyber-attack.I hope to not go to jail