Skip to content

Tag: java

Can’t get a image from resources

I have problem to get an image from another package of my Eclipse project! I saw this post here My code is this I getting this exception: I don’t know what I am doing wrong? Maybe is the a lot hour a have spend already infront of my monitor. Here is my project structure: Thanks for your attention and

Finding date of birth from age in java

Hello all I am creating a program for finding the date of birth when the exact age is given. For example if age of a man is 21 years 10 months and 22 days(up to current date) how can i find the exact date of birth. I will be thankful if anyone help me with isuue. What i tried is

How to load image from URL in Fragment class?

I want to load an image from its URL in Fragment class. I’m loading the image like this: but this method is taking more time to load the image and to open it. If I want to use ImageLoader class like this tutorial, then how to load it in Fragment? Answer Use any 3rd party library like Picasso. Download the

Are non-static final variables useful in Java?

This question discusses the practices of non-static final variables. My first impression is that non-static final variables are useless because final variables cannot be reassigned after initialization. That would mean all the objects created from type Foo would have BAR = 10. When would it be useful, practical, or accepted to use non static, but final variables, like so? So

How to make pattern of numbers in java using only two variables?

this is the required pattern and the code which i used is as you can see i used the variable k to print the numbers. My question is that is there a way to print the exact same pattern without using the third variable k? I want to print the pattern using only i and j. Answer Since this problem

String.valueOf(Integer) always return 1

I’m trying to parse String “2 2 2” and add every symbol ‘2’ in ArrayList. This is my code: I can’t understand why System.out.println(String.valueOf(myIntArray.get(rawSize)));always return 1 ? UPDDATE: I try read file, which contain next text: Here is my Main function: public static void main(String[] args){ My output: When i replace:a_char = line.charAt(charCounter); with a_char = ‘5’;, my output: Can’t