How to learn Java as a C++ programmer?

I have about 2 weeks to learn Java well enough to write android apps. What do I do? I'm pretty well versed in C++ and embedded C.

Attached: 212px-Java_programming_language_logo.svg.png (212x388, 17K)

Other urls found in this thread:

tutorialspoint.com/java/
youtube.com/watch?v=4jh94gowim0
developer.android.com/studio/run/device
amazon.co.uk/Java-easy-steps-6th-covers/dp/1840787538
developer.android.com/studio/build/building-cmdline
vogella.com/tutorials/Android/article.html
pastebin.com/pnSuadQW
developer.android.com/guide/topics/providers/document-provider#java
developer.android.com/training/permissions/requesting
tutorials.jenkov.com/java-collections/list.html
github.com/googlesamples/android-architecture
pastebin.com/GaW8aLpF
pastebin.com/BfrVuGaS
twitter.com/SFWRedditGifs

>I have about 2 weeks to learn Java well enough to write android apps. What do I do? I'm pretty well versed in C++ and embedded C.
I have bad news for you user.

Attached: delthis.jpg (207x200, 7K)

Stop wasting time on Jow Forums and start googling android docs.

Spend more time on Jow Forums. I'm sure you'll learn a lot.

do the needful sir

>Spend more time on Jow Forums. I'm sure you'll learn a lot.
This.
Don't forget to include browsing/posting on Jow Forums on your C.V/resume when looking for a job.

Take everything you know from c++ and think about it in an extremely inefficient and retarded way. Boom you now know Java.

Learn Kotlin instead. Especially for Android

>Learn Kotlin instead. Especially for Android
Fuck off you fag.
Java will always be the king.

Haha no but seriously, I applied for a C++ internship and now they sent me to the java unit testing team. I'm mathematically twice as qualified as half the people in the company but it's okay I guess

The biggest hurdle for me op was Java doesn't support pass by reference in functions. It's pass by value only.

Everything that allocates via 'new' is copy-on-write reference since the latest version of the JVM.

Android Java begin other runtime instead of JVM.
Java on android is like Java8 minus features.

And Android use other toolkit GUI and libs for network,threads ... over traditional JRE, mostly search "Android X feature" over "Java X feature".

tutorialspoint.com/java/
Code this until Java Advance Generics, every other feature is better search android libs or tutorial.

Download android studio, about Android, really learn activity lifetime, Avoid Block UI thread with task and some databases with SQLite

Kotlin

Thanks for this, can I make .apk's for my unrooted phone with that?

read Core Java for the Impatient by Cay Horstmann, it's the best introductory Java book. alternatively, Oracle tutorials, but they are less advanced and move at a much slower pace

Just look up the Java equivalents to C++ keywords and then investigate concepts that don't directly overlap with C++. Duh.

Download and install Eclipse
Download and install the java jdk

It really isn't that hard after that.

>kotlin
True beta-males. OP, take the red pill. Learn Scala.

basically this

enjoy writing system.out.printline("hello"); instead of cout

this. I avoided learning kotlin until this year and its fuckin a complete upgrade over java. still missing some features from swift, like combining conditionals into `lets`, but still beats java.

scala lets you do println("hello")

Yeah well it's still shorter as puts("hello");

>Learn Scala
You mean java's window to fp that gets more and more javaish with each new generation

>scala
youtube.com/watch?v=4jh94gowim0

Download Android Studio, install Usb android on Windows or is automatic on Mac, in smartphone android active "developer mode" connect android phone in computer and execute android in devicer for debugger.

developer.android.com/studio/run/device

To make APK signer is more complex but allow install apps in any android or upload to appstore.

Dude what is wrong with that psychotic ass white dude?
>developer mode
Can't still in warranty. I just want to transfer my .apk via USB to the flash memory

Developer mode don't avoid guaranty and is reversible.

But usually compile application in Android studio build APK you can send to USB device.

In "project name"/app/build/output/apks in this route found apk application file.

Thanks friend, so android java is special java.
What if I want to write in C++? Simple programs.

>Can't still in warranty
Developer mode doesn't void your warranty in any way.
Who told you this?

>in an extremely inefficient and retarded way
can you give some examples or are you talking out of your ass? java is actually one of the fastest languages that aren't compiled directly into machine code (and the performance drops are caused mostly by various runtime safety checks) and thanks to JVM runtime optimizations it can actually be faster in many IRL scenarios. it's also much faster to develop with than C++, that's why POOs like it so much

The shop assisstant. He went to speak to the manager about it.

Setup a build environment and download an open source app and build that.
Then make a few changes to make sure you understand how things work.
Then write your own material design fizzbuzz example.

here is how I learn to code in any language and it is really effective, to learn to code you need problems! Then you work on solving the problem programmatically, this means googling for the solution to the problem and that will teach you everything about that subject or problem, its much easier to learn this way because it is fun.

Take for instance my problem, how to terminate an infinite while loop with a key press using C on the linux OS, all the solutions I found don't work because for some reason there is no conio.h header file on my distro. So now I'm looking at pthread and learning about threaded operations, and off I will go and learn about that which will be really useful in the long run. I'm currently learning C, I started with C# but I fucking hate windows and microdick, I also love using lower level code for most things if I can.

tl;dr

create a problem and learn to build a solution for that problem using what ever language you wish to learn, you will become a better coder than just reading a book.

Maybe it is your country that have some weird laws, but more likely is that he is full of shit.
Flashing another rom might set a warranty bit on the device, but developer mode is no more dangerous than "show hidden files" on a desktop computer

Java as language is same basic function, but Google add a lot special libs for GUI,networking,threads and more. making Java Server or Desktop books useless after basic language features.

JNI for Android, Allow C++ in Android, using clang++ compiler, but this is too hard over just code java for normal apps, C++ code need Java code to begin call, Game engines create simple Java app and build every else in C++.

Usually Call C++ for perfomance, Android Studio get IDE functions for Native Developer Kit,C++ autocomplete and debuggers, but only learn it after learn basic Android.

I have a problem.
Blokada doesn't clean host files of duplicates and I want to change that. But I have no clue where to begin, it's a giant shitfest to me.

Do people mostly make Android programs in Studio? Is it necessary or can you program fine without it?

also I recommend Mike McGrath's books on programming subjects for getting the grasps of the basics. The books are by no means a complete reference but they are so easy to read and cover all the essentials like...

data types
loops
functions
arithmetic
classes (if used)

and basically all the fundamentals of any language.

amazon.co.uk/Java-easy-steps-6th-covers/dp/1840787538

you could probably find a pdf of the book if you are poor.

>Blokada doesn't clean host files of duplicates
elaborate further. Do you have the source code or something?

Yes.

Studio get drag and drop preview GUI builder, debugger and Virtual machine for run apps or phone.

But you can compile and developer android apps without android studio, using command line, but mananger XML GUI without preview ....

developer.android.com/studio/build/building-cmdline

Thanks friend but I know C++ and work as a freelance consultant for companies like vmware and sap.

Yeah it's on github, though it seems to be Kotlin Java whatever that is.
I entered my own hosts with repeating entries into the program and it showed them all in the count.

yeah I just read your OP again, well it should not be too hard to learn java in 2 weeks if you know C++ imo.

vogella.com/tutorials/Android/article.html

Objects are allocated in the heap. When you pass an object to a method it's passed by reference, but in Java everything (except primitive types) is an object so what you're saying makes no sense in the context of Java.

there you go

Attached: java.jpg (427x155, 16K)

erm

string[] hostList = someListOfThings.Split('delimiter'))
List hosts = new List();

for (i = 0; i < hostList.Count; i++)
{

// if we have already added/counted
if (hosts.Contains(hostList[i]);
}
continue;
}

// if not then add/count
hosts.Add(someListOfThings[i]);

}

var count = hosts.Count();

excuse my shit C# code but I'm guessing here on what you require it to essentially do, sounds like it has no checks in place for whether a host has already been counted.

>hostList.Count
kek

hostList.Length()

:>

learning to write android apps is a whole separate beast from just learning java.
Hunker down and learn java's syntax then when youve got that down learn what an android activity is.

What, where is this? I refuse to believe they actually fucking use a linked list of strings.

I am just guessing because I don't know what OP means by it counting

> entered my own hosts with repeating entries into the program and it showed them all in the count.

in reference to his/her other post.

>Blokada doesn't clean host files of duplicates and I want to change that.

OP here, I wrote what I want to add to Blokada in C++ for 3 mins.

pastebin.com/pnSuadQW

Come to think about it, I don't really need that vector of strings

>The biggest hurdle for me op was Java doesn't support pass by reference in functions
why? if you really need to pass something by reference, it's most likely caused by very bad design. pass by reference in C++ is treated more as a syntactic sugar than some much needed improvement over C. maybe you meant something like lack of support for pointers to primitives in Java?
>When you pass an object to a method it's passed by reference
it's still pass by value, to be exact, i.e. the reference to an object is passed by value.

>if you really need to pass something by reference, it's most likely caused by very bad design.
You're retarded

I picked up java on a software contract I took for an Android app. C++ is probably one of the best things you can know before learning java; it's basically a version of C++ designed to stop programmers from shooting themselves in the foot (everything must be in a class, automatic memory management, etc.). It's easy.

The real problem is learning the Android SDK. I'm pro-OOP but it's a fantastic example of OOP gone wrong. The entire API is a fantastic example of unnecessary complexity in the name of fighting complexity. You spend more time in a state of "analysis paralysis" trying to figure out how to understand managing the state of an excessive amount of objects, most of which are instantiated from 'do-ers'; ThingManager, ThingLoader, ThingAdapter, ThingProvider, ThingScanner, ThingRecycler etc. - and everytime they revise the API they split classes into even more classes. Speaking of API revisions, be ready to perform switch statements everywhere to handle fringe cases of old APIs playing up (the support libraries are meant to handle this seamlessly but they are loaded with bugs).

Android studio is a bloated piece of shit, but it will hold your hand while you learn the intricacies of Android. I highly recommend it.

This. You have a lot to pick up on. I suggest starting with reading up on the Android activity life cycle (pic related).
The Android media framework is also a big gotcha if you're used to traditional file operations; to open files you have to talk to the *storage access framework*:
developer.android.com/guide/topics/providers/document-provider#java
Also look into requesting permissions:
developer.android.com/training/permissions/requesting
Once you understand these 3 things the rest is relatively easy.

Attached: activity_lifecycle.png (513x663, 45K)

>I have about 2 weeks to learn Java well enough to write android apps. What do I do? I'm pretty well versed in C++ and embedded C.
Why? One horrible language wasn't enough for you?

cont.

There are way more resources and reading materials for java on Android available. I'd avoid Kotlin if you're not already well versed in Android programming.

Android apps always start from the Android Run Time (java/kotlin) and any native code must be called from it; unless you need to do something that requires freedom from the garbage collector (ie low-level sound or graphics programming) you should stick to the ART.

It's because they know going from writing C++ to java is like going from lecturing at university to teaching first graders. Just practice writing some apps beforehand so you can hit the ground running.

Thanks for the help and encouragement, I may make it

nice argument, you fucking mouthbreather. give a single example where pass by reference is really needed

Reading/writing/returning large objects containers.

>Scala on Android.
Retarded. You won't find a job. If you really want to write Scala - do backend stuff.

The hardest part of android - is figuring out how to deal with the fact that your app may be killed by android at ANY time. Rotate your phone - and BOOM you got a memory leak because you forgot to stop a thread in onStop (and I mean onStop because onDestroy MAY NOT BE CALLED) and other funny stuff like that.

whenever you're passing something larger than a reference?

guhh

you are still not being clear on the problem, you are saying it isn't cleaning up duplicates...

I can only guess that first you will have to load the file you are saving to, and then check if the thing already exists within the file, don't they have some sort of collections thing in java? Yeah they do, then you could add every host already added to a collection list, loop through the new list and check if each already existed? Sorry I really don't know at this point with what you have given.

>don't they have some sort of collections thing in java?
I have no clue but empirically found out Blokada allows duplicate hosts.

and passing the references to those objects by value is insufficient how? do you, fucking idiots, even know what passing by reference is?

>and passing the references to those objects by value
Are you drunk, high, or extremely retarded?

I read code blokada, kotlin is super nice,but error must be

/app/src/tunnel/kotlin/tunnel/FilterManager.kt
This file sync filters

mutableSetOf()
This code must warranty filter don't get repetition but ...

/app/src/tunnel/kotlin/tunnel/Model.kt
Model Filter use String filter url as ID, set must take string.hashcode() for erase repetitions.

System works and manual filter edition don't use MutateSet or some error make mutate set allow repetite filter or ListView in Android GUI don't use set but some list with repetition for load UI.

Search urls in github because 4channel believe hash urls are spam.

It does have

tutorials.jenkov.com/java-collections/list.html

> found out Blokada allows duplicate hosts.

but that's not fixing the problem :D

cont.

You will; also see:
>The hardest part of android - is figuring out how to deal with the fact that your app may be killed by android at ANY time. Rotate your phone - and BOOM you got a memory leak because you forgot to stop a thread in onStop (and I mean onStop because onDestroy MAY NOT BE CALLED) and other funny stuff like that.
Yeah this is another pitfall. Part of the app activity lifecycle is learning to deal with saving/restoring the state of your app when this happens (assuming onDestroy() is called).
I've been doing some openGL stuff recently and it's a fucking nightmare in a similar way - it murders the openGL context at the drop of a hat.

>passing the references to those objects by value
I'm assuming you're referring to instances of the class java.lang.ref.Reference?

Ahhhhh thank you

Don't worry, you'll probably just have to learn the basic differences from C++ (e.g. no explicit pointers but almost everything behaves like a pointer), and you'll be able to write working code. I'm pretty sure this will take like a day at most.
Then you'll need to learn design related stuff (design patterns used in Java, and forgetting about stuff like RAII). If you're a decent C++ programmer (i.e. not writing in C++ like you would in C), this won't take long either.
Then you'll need to just practice, and while doing this you'll learn the standard library, and the cool stuff like streams.

I will look at a C# project I was doing some month ago but stopped, and I will show you what I mean and then you can see if it is relevant, but do note I am by no means a professional programmer.

Great thanks

Bro you want some real advice? Look at the google template android apps and understand how they work. Look at the data separation and ask yourself "why is this done here and not anywhere else?"

github.com/googlesamples/android-architecture

Read up

I'd recommend some basic research on a topic before trying to participate in a discussion about it, but considering that your room temperature IQ so far has prevented you from understanding that passing an object by reference and passing a reference to an object by value are 2 different things, I'd say it's futile.
>I'm assuming you're referring to instances of the class java.lang.ref.Reference?
I'm just referring to commonly called references to objects and how they are copied after being passed to a method. it's different from passing those objects by reference, you can't change the reference that gets passed in, like in e.g. C++ or C#

>passing an object by reference and passing a reference to an object by value
They are one and the same, read some stroustrup or the ISO standard.

pastebin.com/GaW8aLpF

So basically I'm loading from files that are in csv format, they contain various values from indeed job adverts. I wanted to avoid displaying jobs that I have applied too or job adverts that had already been added, so the program always loads previous jobs into Lists, then I can check each new job advert by simply checking if one of its reference values has already been added to the files. Any new jobs are appended to the output files, any jobs over 30 days old are pruned and then re added if an advert for the job still exists.

pastebin.com/BfrVuGaS

Here jobmap_jk is a static List i think... It contains the new jk value from indeed website jobmap, it is a unique reference, so the jk file is opened and imported into a List, then each new jk is checked to see if it already exists, if it does the loop iterates to the next, if not the new jk is added to a list of urls within the app. On program close or some other event, the new lists are appended to the files. This is probably going to be completely irrelevant but what ever man.

Its not the same, theres 3 distinct concepts here

pass by reference -> passes the pointer
pass by value -> passes a copy of the object
pass reference by value -> passes a copy of the pointer

>passes a copy of the pointer
References always degrade to pointer arithmetic, get your head straight. You don't "pass the pointer"

not the guy you're arguing with, but whats your point? that reference & reference by value are the same thing?

>pass reference by value -> passes a copy of the pointer
>pass by reference -> passes the pointer
I'm assuming english isn't your first language. Are you trying to describe a reference and a const reference?

Yes, the mov and lea do the exact same thing.
void test(int& hmm)
{
std::cout

Attached: Untitled.png (348x273, 8K)

I'm assuming that being an asshole is part of who you are, but hopefully you can stop that for a second.

no, I'm talking about pointers and copies of pointers. For example, Java passes references by values

who gives a fucking shit, if you wish to change the fucking variable you pass by reference (unless is global/static), if you don't you pass by value, god damn you people are fucking dense arguing over fucking nothing... I'm sure passing by reference is more efficient as you are not creating a fucking copy... But that might not be what you require.

Thats all you need to know, now SHUT THE FUCK UP...

>Java passes references by values
But you clearly called passing by reference bad design in C/C++

Not really sure if this applies, as java wouldnt compile code like that and java passes references by value

no I didnt. you're too engrossed in winning your imaginary argument to even make a cohesive point

You're extra crispy retarded to be quite honest, and salty to go

suck my fucking dick, you piece of cunt.

> read some stroustrup or the ISO standard.
read some stroustrup about passing references by value in java? references in java work differently than in C++, that's the fucking point. "Are you drunk, high, or extremely retarded?". so you think the equivalent of the following code will work in java?:
void swap(Obj& arg1, Obj& arg2) {
Obj temp = arg1;
arg1 = arg2;
arg2 = temp;
}
Obj var1 = ...;
Obj var2 = ...;
swap(var1, var2);

as e.g.:
void swap(Obj arg1, Obj arg2) {
Obj temp = arg1;
arg1 = arg2;
arg2 = temp;
}
Obj var1 = ...;
Obj var2 = ...;
swap(var1, var2);

jesus fucking christ. I'd say poo in the loo, but most even indians know such basics. I just hope you don't consider a career in IT

Attached: 1.jpg (480x270, 12K)

SEETHE
Don't insult C++ next time negroid

>no, I'm talking about pointers and copies of pointers
When you pass a pointer into a method a copy of that pointer is made for the local scope. Pointers are just integers under the hood.

But that goes against the concept of pass by reference. If you pass a reference to a method then replace the object reference with a new object then the callers pointer now points to the new object. If you're saying that pass by reference always copies the pointer then that above example wouldnt be possible.

e.g.
public static void main(String[] args) {
Dog aDog = new Dog("Max");
foo(aDog);
aDog.getName().equals("Max"); // true if pass by value or reference as value, false if pass by reference (aDog now points to Fifi)
}

public static void foo(Dog d) {
d = new Dog("Fifi");
}

1. watch a couple of videos
2. start coding

if you have to ask i doubt you are "pretty well versed" in any language

Don't

>C++
The first step would be killing yourself

What he's saying is if you pass an int to as a parameter to a method, the method won't be able to modify the int and save it's changes. So if I have x = 5 and call the method addTwo(x) and print the value of x, it would still be 5. Now, if I print the value returned by addTwo(x) it would print 7. This is why you have to return something in virtually every Java method unless it only affects global variables

Oh I get it, you're confusing pointers and pointers to pointers