« first day (862 days earlier)      last day (4303 days later) » 

01:30
Hello, Java!
 
1 hour later…
02:49
HEEEEEEEEEEELP
lol
someone @nathvi me
 
9 hours later…
user142019
11:50
1 message moved from Java Sucks
12:49
hi guys!
how to output string to console ? ))))))))))
 
2 hours later…
14:21
@Nathvi hi
@nazar_art Hahaha :P
@nazar_art System.out.println("hello");
whats the best way to cast object[] to anotherClass[]? Is the only way to build a function which does that?
@FredOverflow I'm pretty sure it was a joke :P
@Lele You could just use a for loop
for (Object o : objectArr) {
i know how...
i thought there must be another way...
Um... not that I know of
14:28
poor javaians :(((
less code ;)
hello @CCI!
In C# we can simply use Linq
hey @Doorknob
@Lele Object[] foo = (Object[]) bar;
or in C#
14:29
@FredOverflow You can't do that
Although you don't need the cast. Arrays are covariant in Java.
var newArray = Array.ConvertAll(array, item => (NewType)item);
i can´t do that
I think you might be able to do System.arrayCopy(arr1, 0, arr2, 0, arr1.length)
Oh, I thought to Object[]. Because that always works.
14:30
Integer[] integerArray = Arrays.copyOf(a, a.length, Integer[].class);
Integer[] integerArray = Arrays.copyOfRange(a, 0, a.length, Integer[].class);
@FredOverflow I am pretty sure casting arrays isn't allowed
(although not positive)
casting arrays is not possible...I'll write a loop ;)
String[] strings = {"hello", "world"};
Object[] objects = strings;
String[] moreStrings = (String[]) objects;
yep that's probably the best way
or you could use my method
14:31
@FredOverflow You can't
hmm java has strange case for built in methods
@Doorknob ideone disagrees with you.
@Doorknob Of course that only works if the runtime type of the array is actually of the correct type.
@Lele Why do you want to do that in the first place?
I have an Linkedlist and have to return an array of a class i have written
and the toArray gives me Object[]
so I thought I just could cast it.....which isn´t possible
14:37
wtf java
public static  T[] convert(Object[] objects, Class type) {
    T[] convertedObjects =
      (T[]) Array.newInstance(type, objects.length);

    try {
        for(int i = 0; i < objects.length; i++) {
            convertedObjects[i] = (T)objects[i];
        }
    } catch (ClassCastException e) {
        log.debug("Exception on convert() : ", e);
    }

    return convertedObjects;
}
convert(objectArrayOfTypeX, TypeX.class);
@Lele There is an overload of toArray that takes an array of the correct type.
MyClass[] a = myLinkedList.toArray(new MyClass[0]);   // or something
33
A: make arrayList.toArray() return more specific types

Mihai Claudiu ToaderLike this: List<String> list = new ArrayList<String>(); String[] a = list.toArray(new String[list.size()]); It's tempting to do it like: String[] a = list.toArray(new String[0]); but the internal implementation will realloc a properly sized array anyway so you are better doing ...

166
Q: What is the XY problem?

GnomeWhat is the XY problem? When asking questions, how do I recognize when I'm falling into it? How do I avoid it? Return to FAQ index

That is, you should have asked us how to convert a list<T> into a T[].
@FredOverflow oh, i overlooked that :P
thanks ;)
Also, Java generics suck. Otherwise, toArray would be able to choose the correct type automatically.
14:44
I've been trying ActionScript
it's good :D
@Doorknob try C#
it's good
maybe
anyone goodz with graphing/math?
I am a bit
^ 1 answer. 8k rep.
lol
14:48
:O
41 answers
30K rep
Denis Bueno, New Mexico
29.5k 3 12 28
@CCInc Just ask the question and we'll see.
this person has 20k with only 10 answers!
more here
well basically I need to grpah a porabula that opens at an angle rather than one direction
like a 45 degree angle?
14:52
something like imm.io/Y4br
you can't (with normal y= type graph notation thingy)
there are multiple xs for each y
user142019
@FredOverflow -1 needs more fmap.
user142019
Arrays are endofunctors; treat them as such.
user142019
Monads, even.
user142019
15:09
objects >>= new Function() { @Override String Apply(object o) { return (String)o; } } lol
user142019
objects.bind(new Function() { @Override String apply(Object o) { return (String)o; } }) I'm used to C# naming conventions.
user142019
Dammit wait.
user142019
objects.bind(new Function() { @Override String[] apply(Object o) { return new String[] {(String)o}; } })
user142019
Fuck you Java!
user142019
from o in objects select (string)o :)
16:42
How we can check Mime type?
class ProbeContentTypeCheker implements Checker {

@Override
public boolean check(File fileCheck) {
String mimeType = new MimetypesFileTypeMap().getContentType(fileCheck);
if (mimeType == null) {
return false;
}

return true;
}
}
is this variant correct?
 
5 hours later…
21:38
Hey guys, can someone help me. I'm still not too sure on the difference between recursive and non-recursive methods. I've created a method to check for leap year, and it has to be non-recursive. If I show you a paste of the code can you tell me if it's non recursive please?
recursive is when a method calls itsef
like
public void neverEnding()
{
neverEnding();
}
this example makes no sense...but in many cases it does
Soo, is this non-recursive then? Because I call the method with the println
no, its not
recursive
ok, thank you, I was confused about the calling the method from the println cuz I thought that might have meant it was recursive lol
no recursive is when it calls ITSELF
like if you are searching for a file
21:42
Yes, I understand that now LOL
thank u
and you are in a directory
already understuud?
I bloody hope so!
anybody out there?
I am ;)
good god
I really need some help
I'm writing this project for class, and its taking a big shit on me
21:55
kk
that's my code
Here's what I want it to do
whats the problem?
everything XD
I want it to input first and last name
then input 4 test scores
then ask if we want to enter another student
if "y", then we loop, else, display class results
It's so fucked
this should be simple
kk
the first point
to make this simple
is that every logic "unit" should have his own function
its not his :P
22:00
?
whats not whose?
is that every logic "unit" should have his own function
is that every logic "unit" should have *its* own function
Hehe
ok, so i revised to code
:D
Kidding :P
it works how I want it to
except
I just need to figure out a way to input the total sum for each student
22:02
of scores
I know I need a loop
or what
and an array
yes
Please enter the name of student 1: bill nom
Please enter score for Exam 1: 1
Please enter score for Exam 2: 2
Please enter score for Exam 3: 3
Please enter score for final Exam 4
Do you wish to enter another? <y/n>: n

***Class Results***
nom,bill Exam Percentage: 0
the "nom,bill" is right
I need to sum the total for each student, and put it in an array
then divide by 250
that will be the total score
ah ok
after that, I need to display a letter grade
22:05
do you know what a function is? ;)
so the correct format would be
I know what it is, but we haven't covered that yet...
I could do it in python
:(
                                    int score_Sum = 11;
                                    int exam_Percentage =  score_Sum / 250;
is that the part where you want to calculate the test scores?
yeah, I just made mock up of it
SIMPSON, HOMER Exam Percentage: 74.8 Final Grade: C
^ is what the format is supposed to look like
I just added a .toUpperCase()
so like
for (int i = 0; i < 4; i++)
{
forget this code...
ill do it in the pastebin
I already have that set up in my program
int score_Sum = 0;
but I also need it to input into an array
22:10
but you said you have 3 scores
no 4 scores
i think your programm is wrong
you have 4 test, right?
yes
you first have the loop for the students
inside this loop
you ask for the name
then you have another loop inside this loop
for the 4 tests
hmm, lets first see your code...
I need some kind of score sum array
22:15
yeah
that should be easy
you can add to this array like array[1] = array[1] + newSum;
my output should look like:
System.out.println(last_Name_Array[super_Counter].toUpperCase() + "," + first_Name_Array[super_Counter].toUpperCase() + " " + "Exam Percentage: " + (double)score_Sum[index]/250 );
right
i have to leave...
off to make an array
o no!!!!
Bye :(
damn
anybody else got an idea how to do this?
here's my updated code
here's the output of the program
Please enter the name of student 1: bill nom
Please enter score for Exam 1: 1
2
Please enter score for Exam 2: 3
Please enter score for Exam 3: 4
Please enter score for final Exam 5
6
Do you wish to enter another? <y/n>: n

***Class Results***
NOM,BILL Exam Percentage: 0.032
(I just inputed 1,2,3,4,5,6)
for some reason
it only inputs the 2 and the 6
23:07
hola
@Lele
I'm o so close now
it only inputs in the first and the last values... idk why
23:58
hi @Nathvi @Lews @CCInc
:D
@Doorknob
please
for the love of god
and all that is holy
please help me
this program is kicking my ass
jst a sec, leme paste the code
23:59
NO
don't
put code here
put on pastebin

« first day (862 days earlier)      last day (4303 days later) »