Questions tagged as 'java'

1
answer

What does the term "String ... string" mean in Java?

What does the term String... string mean in Java? And how to construct a method that returns a String... as an example: public String... getStrings(){ return String... s;) } I know it's not that way, but I wanted to know...
asked by 01.02.2016 / 14:52
1
answer

Methods that require return even though Void in the "signature"

I'm doing some tests to understand in practice how the class works SwingWorker in% of%, and I noticed that the swing method requires doInBackground return, even starting the variable of the form below: SwingWorker<Voi...
asked by 21.03.2016 / 16:34
2
answers

What is the difference between Math.random and java.util.Random?

What's the difference in using random without import , right in method. public class random { public static void main(String[] args) { int x = (int) (Math.random() * 10); System.out.println(x); } }...
asked by 13.02.2016 / 15:14
1
answer

Passing optional arguments in Java

I'm trying to learn how the class works SwingWorker<T,V> , I have already done another question regarding one of his methods. Looking at the source code of this class, I found the publish() method written as follows:...
asked by 22.03.2016 / 23:17
1
answer

Why is the image distorted (does not maintain proportions) in ImageView?

I have some images inside the folder drawable and I call them via code: public void inserindoImage(ImageView image,int rid,LinearLayout linear ) { image.setBackgroundResource(rid); linear.addView(image); } Wh...
asked by 22.03.2016 / 14:43
3
answers

Infinite object?

I ended up doing something that made me curious: I created a following Cao class: public class Cao { String nomeDoCao = null; Cao caes = new Cao(); public void setName(String name) { nomeDoCao = name; } publi...
asked by 22.07.2014 / 02:48
3
answers

What is the best way to replace a character in a given String position?

I need to replace a character at a certain position in String (). Example - Change character [21] to 'X': Original String = 01078989469150999134B B 2116456 Modified String = 01078989469150999134B X 2116456 I'm using the follo...
asked by 01.08.2014 / 20:56
2
answers

Send objects via socket

I have a chat that exchanges messages ( String ) with each other. Everything is working properly. But now, I want to start sending objects via Socket , for example, a class that has some attributes set by me (eg, name, IP, host name,...
asked by 16.07.2014 / 04:21
1
answer

How to handle security in a REST application with Spring?

I'd like to know how I could handle the security of a stateless REST application with Spring. Imagine that no user can access any content of /app/content if you have not first identified. Is there any way to do this without also having...
asked by 08.10.2014 / 19:23
2
answers

Doubt in inheritance

I have a question about inheritance. I have the following code: public class CovariantTest { public A getObject(){ return new A(); } public static void main(String[] args){ CovariantTest c1 = new SubCovariantTest(...
asked by 28.05.2015 / 16:31