prepping for an exam, new to java & might need help understanding some stuff

im just gonna put in questions here as I study ill probably not ask a whole ass program explanation unless its fully indecipherable to me ill bold whatever is the tldr version if you dont want extra context
30 Replies
JavaBot
JavaBot8h ago
This post has been reserved for your question.
Hey @Piglet | NEED tone tags!!! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Piglet | **NEED** tone tags!!
firstly, whats a null literal 😭 ik it represents like no value but the text says "null is used to initialize an object of a class ... and may denote non-availability of a character in a String" secondly, ill need to do conversions from/to decimal, binary, hexadecimal and octal numbers but if anyone happens to know a method thats easy for any of that pls lmk
Piglet | **NEED** tone tags!!
this is what we've been taught, I just have some trouble w I. & II. cuz im not great at calculations
No description
dan1st
dan1st8h ago
null is a special value to indicate that there is no object. https://stackoverflow.com/a/19654040/10871900 The null literal is the text null that refers to that value
Stack Overflow
What is the difference between null, 0 and nothing?
What is the difference between null, 0 and nothing? I cannot find a question addressing all three of these. For example: If I am getting input from a string and parsing it to int. return Integer.
dan1st
dan1st8h ago
So every reference variable (so variables that are not primitives like boolean, char, short, int, long, float, double can be null meaning "no value associated with it" and you can explicitly set a variable to null using yourVariable = null; or check whether a variable is null using if(yourVariable == null) {}
dan1st
dan1st8h ago
Stack Overflow
What is null in Java?
What is null? Is null an instance of anything? What set does null belong to? How is it represented in the memory?
Piglet | **NEED** tone tags!!
okay so like, its ONLY for non-primitive datatypes, but if I wanted to do pretty much the same thing w a primitive data type, smth like int example = 0 or String ex2 = "" works right
dan1st
dan1st8h ago
Piglet | **NEED** tone tags!!
oh I cant use code
dan1st
dan1st8h ago
The value 0 is a normal int and Strings are not primitive so a String can be null (which is usually not that good of an idea)
Piglet | **NEED** tone tags!!
its a written exam, might have to write some programs but other than a simple calculator I cant use anything else okay, thanks
dan1st
dan1st8h ago
Well you can still use Integer.parseInt om your cpde
Piglet | **NEED** tone tags!!
I mean the questions for that are gonna be like: "Convert 110101001 to hexadecimal" and id have to work it out myself
dan1st
dan1st8h ago
String hexadecimal = "A5";//a string with a number in hexadecimal
int convertedToInt = Integer.parseInt(hexadecimal, 16);//convert the hex (16) string to an int for further processing
String toBinary = Integer.parseInt(convertedToInt, 2);//convert the int to a binary (2) string
String toDecimal = Integer.parseInt(convertedToInt, 10);//convert the int to a decimal (10) string
String hexadecimal = "A5";//a string with a number in hexadecimal
int convertedToInt = Integer.parseInt(hexadecimal, 16);//convert the hex (16) string to an int for further processing
String toBinary = Integer.parseInt(convertedToInt, 2);//convert the int to a binary (2) string
String toDecimal = Integer.parseInt(convertedToInt, 10);//convert the int to a decimal (10) string
oh you mean without code? There are a few techniques for it
Piglet | **NEED** tone tags!!
for program questions theyre like "A Piglatin word is the part of the word after the first vowel, the part before, added with an 'ay'" and I'd have to use like substring and loop commands to get that output yup
Want results from more Discord servers?
Add your server