-  [WT]  [PS]  [Home] [Manage]

Posting mode: Reply
  1.   (reply to 4501)
  2. (for post and file deletion)
/pr/ - Programming
  • Supported file types are: C, CSS, DOC, DOCX, GIF, H, JAVA, JPG, PDF, PNG, SVG, SWF, TXT, WEBM
  • Maximum file size allowed is 10000 KB.
  • Images greater than 200x200 pixels will be thumbnailed.
  • Currently 398 unique user posts. View catalog

  • Blotter updated: 2018-08-24 Show/Hide Show All

There's a new /777/ up, it's /Moldy Memes/ Check it out. Suggest new /777/s here.

Movies & TV 24/7 via Channel7: Web Player, .m3u file. Music via Radio7: Web Player, .m3u file.

WebM is now available sitewide! Please check this thread for more info.

Neckbearded Basement Dweller 14/07/03(Thu)05:32 No. 4501

File 140435837030.png - (141.51KB , 1178x583 , SDFDSFSDFSDF.png )

This author is really starting to piss me off. I paid 15 dollars for this shit, and I think I have picked out two huge errors he has made. Book is Java 7 for Absolute Beginners, by Jay Bryant.

First example:
On page 79, he says that

int a = 0;
int b = 1;
String s = "s";
String sToo = "s";
System.out.println(a == b);
System.out.println(s == sToo);

will generate the results "true" and "false" respectively. Eclipse begs to differ. Here's what it says:


My question is, how does this guy pass for being an instructor when he can't even get it right? I will post the page before as well.

Neckbearded Basement Dweller 14/07/03(Thu)05:33 No. 4502

File 140435840887.png - (153.28KB , 1208x604 , sdfsdfsdfsdf.png )

Other side

Neckbearded Basement Dweller 14/07/03(Thu)05:41 No. 4503

File 140435889478.png - (149.90KB , 1094x564 , SFSFSDFSFD.png )

Problem number 2. Perhaps I'm overlooking something, but here it is.

1 page later, he claims that

Byte byte1 = Byte.parseByte("01010101", 2); // byte1 = 85
Byte byte2 = Byte.parseByte("00111111", 2); // byte2 = 63
int result = byte1 ^ byte2; // result = 106

will give me the binary of 106 which is 01101010, which is fine since it does equal 106.

But then he says literally the exact same thing for the example using the | operator, where the outcome produces a 01101010 binary code (same as 106's) but this time it generates 127.

Byte byte1 = Byte.parseByte("01010101", 2); // byte1 = 85
Byte byte2 = Byte.parseByte("00111111", 2); // byte2 = 63
int result = byte1 | byte2; // result = 127

What the fuck is going on here?

Neckbearded Basement Dweller 14/07/04(Fri)05:32 No. 4505

He used two different meanings of "either", first to mean "exactly one of two options" (e.g. "either x or y") and then to mean "at least one of two options" (e.g. "either of x and y"). It's confusing and poorly written, but technically correct.

Neckbearded Basement Dweller 14/07/04(Fri)11:42 No. 4506

File 140446697647.jpg - (81.49KB , 800x450 , futurama-reference.jpg )

>technically correct.

OP, anyone can write a book. Getting it to sell enough to be worth the time wasted is a different matter.
Being practical, you can either continue suffering or get another book. Look up what are the top 5 or so books, look over them and get the one that sucks less.

Neckbearded Basement Dweller 14/07/04(Fri)16:28 No. 4507

How the fuck is that technically correct?

Neckbearded Basement Dweller 14/07/04(Fri)16:31 No. 4508

His description of the ^ and | operators are literally the same. Read again.

daoluong 14/07/10(Thu)00:20 No. 4509

that book for Absolute Beginners
Absolute Beginners are some kind of retard never read the entire contents
like >>4506 said anyone can write a book
who know if writer is an elementary teacher

you can find another book
or code it yourself like you did
all I see are few typo, writer mixed from other books without checked

Neckbearded Basement Dweller 14/07/30(Wed)21:48 No. 4539

I don't know what was going through his head when he said that 1==0 would return true.

But s=sToo should also return false by conventional wisdom. It was that way when I learned java a few years ago. However, that appears to have changed. There's some sort of behind-the-scenes stuff going on that makes Strings of the same value refer to the same thing. Doesn't work with explicitly declared new Strings though.

And it works on very long Strings. And Strings in separate methods. Can't be arsed to make a new class, but it probably works there too. It'd be awful if it wasn't consistently doing this. Personally, I'd say to just stick with x.equals(y) unless you find a source for the exact new behavior.

Here's my code:
public static void main(String[] args) {
String f = "dicks";
String d = "donger";
int a = 0;
int b = 1;
String s = "s";
String sToo = "s";
String x = new String("abc");
String xToo = new String("abc");
String v = "longass string omitted here for brevity";
String vToo = "longass string omitted here for brevity";
String fToo = "dicks";
String dToo = donger();
System.out.println(a == b);
System.out.println(s == sToo);
System.out.println(x == xToo);
System.out.println(v == vToo);
System.out.println(f == fToo);
System.out.println(d == dToo);

public static String donger()
return "donger";


Neckbearded Basement Dweller 15/02/26(Thu)23:54 No. 4700

s==sToo because Java has references instead of pointers. When you make a new String(), then you create a different memory location. It's confusing as all hell.

Nattajerk 15/03/04(Wed)22:29 No. 4702

i tend to get book reviews long before i buy a book these days, after being stung by C++ Primer Plus and Learning PHP & MySQL before, not even the animal books are safe from bad authors.

doing your homework requires doing your homework to do your homework, it's ridiculous.

4503 inter 15/04/22(Wed)23:04 No. 4727

Neckbearded Basement Dweller 15/06/15(Mon)10:09 No. 4760

if two constant strings are of the same value they will likely be interned and share the same ref so:
String s1 "123";
String s2 "123";
s2==s1 will be true as the are really the same ref.
but if one or the other is modified, the ref will change
for reliablity use the equals method on objects and == on primitives
which also means on your own classes you may need to override the equals method

[Return] [Entire Thread] [Last 50 posts]

Delete post []
Report post