[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

guys help how do I do this in java its pretty hard pic related

The stories and information posted here are artistic works of fiction and falsehood.
Only a fool would take anything posted here as fact.

Thread replies: 77
Thread images: 11

File: 2017-01-19-042821_462x357_scrot.png (24KB, 462x357px) Image search: [Google]
2017-01-19-042821_462x357_scrot.png
24KB, 462x357px
guys help how do I do this in java
its pretty hard
pic related
>>
You should stick to C/C++!
Java sucks, hate it
>>
File: raised eyebrow frown.png (231KB, 357x346px) Image search: [Google]
raised eyebrow frown.png
231KB, 357x346px
>>719503993
> Using "print"
>>
>>719504159
I have to for a stupid class
>>
>>719504262
how would you format then?
>implying puts()
>>
>>719504159
What an asnwer!

>>719503993
public class Atoi {
public static void main (String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);

int mul = a*b;
int sum = a+b;

System.out.println("* = " + mul + "\n" + "+ = " + sum);
}
}
>>
>>719503993
>posting in b
>>
>>719503993
what kind of theme or wtf is that
>>
File: stewie griffin.jpg (48KB, 800x1274px) Image search: [Google]
stewie griffin.jpg
48KB, 800x1274px
>>719504262
>cout
>>
>>719504159
With this in my mind, I'll still help out:
Java gets parameters too, as 'args' [Main(string[] args)], and to parse the to int you'll do:
int ni = Integer.parseInt(args [i]);
>>
>>719504408
what's with this public class stuff
can it be private?
>>
File: clean.png (17KB, 820x313px) Image search: [Google]
clean.png
17KB, 820x313px
>>719503993
>>719504408
...and here the "clean" version.
>>
>>719504532
java doesn't have something like printf?
>>
>>719504515
I'm implying that it's in its own file...
Atoi.java
>>
>>719504408
There's a chance that the first argument will be the name of the program, so make sure it's not args[1] and args[2]
>>
>>719504532
so let me get this straight
the things in blue are classes
classes are methods and data into one
classes can inherit from other classes, be children etc,

so if I want the jvm to run some method within a class, I have to name the file as the class too?
>>
>>719504515
public means that it is accessible from members that are not a part of the class ya dingus.
>>
File: atoi_with_print.jpg (58KB, 651x420px) Image search: [Google]
atoi_with_print.jpg
58KB, 651x420px
>>719504563
lol now it has
No, just kidding. Java doesn't have a simple "print", like for example python has.
>>
>>719504684
Yes! If the only and public class has a name that is NOT the name of the file, it will not compile.
>>
>>719504716
That's a verbose language.
>>
>>719504588
nigga you dumb?
args are additional arguments.
>>
>>719504716
so what's the big deal about oop
can java into pointers
>>
>>719504588
Nice dubs! I never heard of that in Java though. When I compile my shit in Eclipse, the arguments are always only the ones I give it to.
>>
>>719504429
what do you mean?
>>
>>719504790
True. Before starting actual things, you have to define lots and lots of things. There's a reason why people prefer scripting languages for smaller tasks.
>>
>>719504867
No. Just No. Sorry!
>>
>>719503993
Lmao I bet haskell has a shorter version of this
>>
>>719504867
java has no pointers but objects are pretty much always referenced (same functionality) unless your object is either a primitive datatype or a immutable custom object.
>>
>>719504716
wait, + is for integers and strings??
>>
>>719505042
Exactly. For other cases, just clone the overload parameters before doing stuff.
>>
>>719504716
Is there only one main like in C and Haskell?
>>
>>719505062
Yes! It's called polymorphism. The println function combines, like some other functions, strings when they are separated with a '+'.
>>
>>719504563
System.out.println('Shitty string');
>>
>>719505199
If ' is used for strings, then how do you do chars in Java?
>>
>>719505172
Polymorphism for me means working on other types of number like floats or complex numbers, but adding in strings seem strange.
>>
>>719505170
Kinda. If you export a bunch of classes of a so called runnable jar-file, you must declare which class to take. Therefore it guarantees that it exports the right class in case many classes within a package or source folder have their own mains.
>>
>>719505229
'char' <-> "String"
>>
>>719505229
It is the other way round.
' for chars
" for strings
>>
>>719505291
So everything is a class huh.
>>
>>719505663
Yes. Therefore, technically speaking, Java has no functions, only methods.
>>
>>719505706
by that definition, c's printf is polymorphic
>>
>>719505706
I'm sure I heard it in the operator context as well.
>>
>>719505737
where'd you learn java
>>
>>719505737
kek
>>719506104
>>
>>719506104
Taught myself coding since I hung out with the nerd kids at school, and we all loved coding. I started with Visual Basic though, learned some other languages, now I stick with Java because I use scientific packages that only exist in Java (the Chemistry Development Kit, to be exact).
>>
>>719506423
What's so kek about it?
>>
>>719506454
so you're a programmer or a chemist?
>>
>>719506515
Neither. I'm a pharmacist, but I also have a master's degree in pharmaceutical sciences and technologies. I focus on computer-aided drug design.
>>
>>719506661
You can create drugs?
>>
>>719506739
I can suppose chemical structures that prove as "drug-like" and provide certain features that could give a hint whether it can do something to your body or not. Shit's all heavily theoretical. I also have some lab experience though, since I had an internship during my master study in a drug synthesis lab.
>>
>>719506870
You have interesting background, don't know what you're doing in /b/ lol.
GOod luck
>>
>>719506953
Thanks. But doing science doesn't mean that I'm not a /b/tard.
>>
>>719503993
https://www.tutorialspoint.com/c_standard_library/c_function_atoi.htm
>>
Java has "System.out.format" a la printf
>>
>>719508806
how can a more modern language not have a more sophisticated formatting function?
>>
>>719509410

System.out.format is there from the start of Java to try and bait C-programmers to switch over. It's recognisable.

Println is the most modern Java has I think, remember that Java is from the 90s
>>
>>719509643
why is java popular
what does it bring to the table?
>>
>>719509720

Object orientation. Was new back then (In a non-academic language)
>>
File: Best fizzbuzz.png (8KB, 287x128px) Image search: [Google]
Best fizzbuzz.png
8KB, 287x128px
Can your language even do this?
>>
Just use awk:

$ echo 1 -1 | awk '{printf "* = %s\n+ = %s\n",$1*$2,$1+$2}'
* = -1
+ = 0
>>
>>719510062
can YOUR language even do THIS?
for i in range(1,101): print "FizzBuzz"[i*i%3*4:8--i**4%5] or i
>>
>>719510417
That's pretty hot actually.
>>
>>719510417
>le unreadable code
pic related is the most readable and most pretty looking code ever
>>
>>719511006
>putStrLn . fizzbuzz
U N R E A D A B L E

also
>putStrLn
wtf, can't they just do print
>fizzbuzz n \n \t \t \t \t = case
lmao what the fuck is this
>>
>>719511006
multiple entities to perform a switch operation on
i must admit this is pretty damn cool
>>
>>719511006
That's the same as >>719510062
You twat.
>>
>>719510062
Can your language even do this?

let i=0;
while(i<100) i++, console.log([i,'fizz','buzz','fizzbuzz'][(i%3==+[])+2*(i%5==+[])]);
>>
File: disgust.jpg (19KB, 367x332px) Image search: [Google]
disgust.jpg
19KB, 367x332px
>>719512596
>imperative programming
>>
File: Csr.jpg (44KB, 800x636px) Image search: [Google]
Csr.jpg
44KB, 800x636px
>>719512838
>2017
>using any programming language other than javascript
>>
>>719512978
>javascript
>a language who's foundations were made in 5 min

lmaoing @ ur life
>>
>>719503993
int
main()
>>
>>719513371
>he doesn't write his functions like that
>>
File: 1484771940161.jpg (7KB, 306x273px) Image search: [Google]
1484771940161.jpg
7KB, 306x273px
>>719512978
>>
Pointer to a pointer to an array of chars for arguments.
This is why Java is superior.
>>
>>719515917
>he doesn't know that it signifies an array of strings

also, stop being a brainlet
>>
>>719516033
>Primitive programming jargon
>brainlet
kys
>>
>>719512596
Can your language even do this?

︵‿︵(´ ͡༎ຶ ͜ʖ ͡༎ຶ `)︵‿︵
Thread posts: 77
Thread images: 11


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.