Java Queries Here..

quad_master

Tired of being sorry!
https in java

i need some basic concept how to implement https in java...do u have any reference/tutorial/links...i wanna understand it...:D
no code please...!!!
 

sganesh

Journeyman
hi Guys,
I ve one SCJP question,pl gimme answer with explanation.
Thanks in Advance....
----------------------------------------------

public class ThreadStarter extends Thread
{
private int x= 2;
public static void main(String args[]) throws Exception
{
new ThreadStarter().makeItSo();
}
public void ThreadStarter(){
x=5;
start();
}
public void makeItSo() throws Exception {
join();
x=x- 1;
System.out.println("answer:"+x);
}
public void run() {
x*=2;
}
}
--------------------------------------------------------
 

chandru.in

In the zone
As I hinted, ThreadStarter() is a method and not a constructor. Hence the default constructor which leaves x untouched is invoked. And later makeItSo() you are decrementing it and hence the output 1.
 

chandru.in

In the zone
Constructors in Java should not have any return type (not even void). The moment a return type is specified, it turns into a normal method and hence not invoked during instantiation.
 

gary4gar

GaurishSharma.com
I am Reading Java Series on "Core Java" by Sun MicroSystems Press. It is written by Cay S.Horstmann & Gary Cornell. Although the book is really Good and explains each aspect of java API & associated libraries.

But wonder why they are so much against C/C++:|

anyways, the Book is good read for *programmers* looking to switch to Java. as anyone learning to code first time should skip this. don't believe me check out the first HelloWorld programs given in chapter 1:p
 

chandru.in

In the zone
But wonder why they are so much against C/C++:|
Because those are the languages whose shortcomings, Java was meant to solve. Today C/C++ and Java rule entirely different territories.
as anyone learning to code first time should skip this. don't believe me check out the first HelloWorld programs given in chapter 1:p
I have never read that book. Can you post the code for us to view?
 

gary4gar

GaurishSharma.com
Code:
public Welcome {
public static void main(String args[]) {

String[] greeting = new String[3]; 
greeting[0] = "Welcome to Core Java";
greeting[1] = "by Cay Horstmann";
greeting[3] = "and Gary Cornell";

for(int i = 0; i < greeting.length; i++)
System.out.println(greeting[i]);
}

}

this is a first program given in the book. the authors call Welcome program extremely simple.

Indeed its simple for programmers but for newbies its a steep learning curve, they have use concepts of arrays,loops etc right into the first program;)
 
Last edited:

chandru.in

In the zone
Code:
public Welcome {[INDENT]public static void main(String args[]) {[/INDENT][INDENT][INDENT]String[] greeting = new String[3]; [/INDENT][/INDENT]
this is a first program given in the book. the authors call Welcome program extremely simple.
Please check whether you typed in properly. I really don't think it would be this crappy. :confused:
 

chandru.in

In the zone
Code:
public Welcome {
public static void main(String args[]) {

String[] greeting = new String[3]; 
greeting[0] = "Welcome to Core Java";
greeting[1] = "by Cay Horstmann";
greeting[3] = "and Gary Cornell";

for(int i = 0; i < greeting.length; i++)
System.out.println(greeting[i]);
}

}
this is a first program given in the book. the authors call Welcome program extremely simple.
Note: You missed "class" in the first line.

Ha ha ha. ROFLMAO. Thank God they did not introduce design patterns too in the same program. That's why I so love Head First series.
 

ravidawar

Broken In
i want to write a java program in which i need to call the command prompt and then run commands like ren , copy over files in a directory inside a for loop.can anyone suggest me how to do that.i tried with process and runtime but not able to achieve what i want.
 
Top Bottom