Java 在方法param内声明列表或在方法param内提供引用时的不同行为

Java 在方法param内声明列表或在方法param内提供引用时的不同行为,java,authentication,cookies,forms-authentication,session-cookies,Java,Authentication,Cookies,Forms Authentication,Session Cookies,我有一个程序,可以使用post方法对网站进行身份验证,并获取一些数据 要做到这一点,我必须储存饼干。 类InfoAuthenticator的方法getCookies()向站点发送post请求并收集cookies ViewNoticesPageReader http = new ViewNoticesPageReader(); http.setCookies(InfoAuthenticator.getCookies()); http.readData(); //sends get request

我有一个程序,可以使用post方法对网站进行身份验证,并获取一些数据

要做到这一点,我必须储存饼干。 类
InfoAuthenticator
的方法
getCookies()
向站点发送post请求并收集cookies

ViewNoticesPageReader http = new ViewNoticesPageReader();
http.setCookies(InfoAuthenticator.getCookies());
http.readData();  //sends get request to fetch html pages
此代码工作正常。但这并不

List<String> cookies=InfoAuthenticator.getCookies();
ViewNoticesPageReader http = new ViewNoticesPageReader();
http.setCookies(cookies);
http.readData();  //sends get request to fetch html pages
List cookies=InfoAuthenticator.getCookies();
ViewNoticesPageReader http=newviewnoticespagereader();
http.setCookies(cookies);
http.readData()//发送get请求以获取html页面
我不明白这两种代码之间的区别。
“不工作”是指我没有通过网站的身份验证。

令人困惑的是,
cookies.size()
在这两种情况下都返回
0

什么是
InfoAuthenticator
类?我无法用谷歌搜索…@Zabri我已经创建了那个类。这会将post req发送到我的站点以获取登录名并从中获取Cookie。如果
InfoAuthenticator.getCookies()
真的返回
List
ViewNoticesAgerReader.setCookies()
真的以
List
为参数,这让我感到吃惊…@Zabri返回类型的
InfoAuthenticator.getCookies()
http.setCookies()的
和arg类型是
List
除了调用方法的顺序之外,没有区别。您的方法调用是否会产生修改某些状态的副作用?